Comment out broken Unique Visitors chart (#12823) - #12831
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR appears to disable the “Unique Visitors” chart on the home stats page and stop fetching visitor counts from Graphite, with corresponding updates to the i18n message template.
Changes:
- Commented out the “Unique Visitors” chart and its graph JSON payload in
home/stats.html - Disabled Graphite-backed visitor count retrieval in
openlibrary/core/admin.py(now returns an empty list) - Updated
messages.potto reflect removed/changed translatable strings and source references
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| openlibrary/templates/home/stats.html | Comments out the visitors chart block and its JSON graph data script |
| openlibrary/i18n/messages.pot | Removes/adjusts message entries/source refs to match template/code changes |
| openlibrary/core/admin.py | Replaces Graphite fetch implementation with a hardcoded empty result |
444fef9 to
2f4f439
Compare
|
Thank you for the PR, @Sadashii! A reviewer must first be assigned. There are currently 14 open PRs of equal or higher priority ahead of yours. PR triage checklist (maintainers / Pam)
Note This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting. |
|
This PR needs significant work and as is implemented I believe creates work for us. It partially un-implements a feature, while leaving some pieces intact and fully removing other parts, resulting in an incoherent solution that will not be accessible to others maintaining the project. The code should simply be updated such that:
Also, please kindly provide a screenshot in the PR to give reviewers confidence so we can put it on testing. |
2f4f439 to
f9ed54a
Compare
|
Updated so when there is valid result the visual are shown, when the response is missing, the visual is also hidden. |
f9ed54a to
0767328
Compare
for more information, see https://pre-commit.ci
|
Plan (Ada, on behalf of Mek): Picking this PR up to narrow the diff per Mek's review comment: "The code should simply be updated such that: If the data is fetched and there is no data, don't render that chart." Scope of the follow-up commit(s), on top of Sadashii's existing work (not rewriting/rebasing their commits):
Testing: Playwright browser verification of both a normal response (all 5 charts + tooltips render/behave like master) and a simulated empty-visitors response (only that chart disappears, no layout break, tooltips still visible above chart), console-clean in both cases. Plus full Phase 7 checklist (pre-commit, Docker tests, a11y, HTTP 200 on homepage + admin). Will push directly onto this branch ( |
|
Note (Ada): |
Per review: only the visitors chart needs conditional rendering when
Graphite data is empty/unavailable. Restore members/edits/lists/ebooks
to their original unconditional wrapper structure on the homepage
(static/css/components/home.css, openlibrary/templates/home/stats.html)
instead of un-wrapping all five charts.
Also:
- Move the repeated inline width/height style on each #{id}-graph div
into a shared .chart-graph CSS rule.
- Fix homepage sparkline tooltips (#chartLabelA) rendering behind the
chart: they were missing z-index, unlike the equivalent tooltip in
loadEditionsGraph() in the same file, which already sets z-index: 100.
Root cause confirmed in-browser: <main> establishes a stacking context
via `position: relative; z-index: 1`, which sits above any z-index:auto
sibling appended later to <body> regardless of DOM order.
12938c8 to
40c4aea
Compare
|
Hi — I'm Pierre, an AI-assisted PR tidier running on behalf of @mekarpeles. I made a small history cleanup on this branch:
Why: removes a bot-generated commit that doesn't add information, making the history easier to review. The bot's fix (import ordering in Safeguards: The folded commit (06a61c7) and the bot commit were the only two touched — no commits by @Sadashii were rewritten. Zero unresolved review threads before pushing. Used To reverse: run |
|
Ada: Copilot/CodeQL review cycle checked post-push — no CodeQL/code-scanning check runs in this repo's CI, and all 7 existing Copilot review threads were already resolved (addressed by earlier commits on this branch). Nothing new to fix or reply to. CI is green (AccessLint, javascript_tests, labeler, pre-commit.ci, python_tests) and the branch is mergeable. This PR is ready for human review — over to Mek. |

Closes #12823
Dynamically hides the Unique Visitors stats charts on the homepage and the admin dashboard when visitor counts data is not available (such as when the upstream archive.org Graphite pipeline is down).
Technical
openlibrary/templates/home/stats.htmland on the admin stats pageopenlibrary/templates/admin/index.htmlwith a$if stats["visitors"].get_summary(28):template conditional.$# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing.timeout=5parameter to the Graphite request inopenlibrary/core/admin.pyto prevent hangs when the Graphite server is down.Testing
Verify style checks:
Screenshot
With valid response,

With missing/invalid response,

Follow-up (Ada, on behalf of Mek): narrowed the diff + fixed a tooltip bug
Mek's review asked for a smaller, more surgical diff than the one above — see this thread for the full plan. Commit
06a61c702(pushed on top of the commits above, nothing rewritten/rebased):.chartShowwrapper div and its CSS rule from all five charts (visitors/members/edits/lists/ebooks) inopenlibrary/templates/home/stats.html/static/css/components/home.css, even though only the visitors chart needed conditional rendering. Restored members/edits/lists/ebooks to master's original wrapper structure — they're unconditional, unchanged in behavior.$if stats["visitors"].get_summary(28):gate around the visitors chart's markup and itsgraph-json-visitors-graphscript tag (homepage) — confirmed the admin page's equivalent gate was already scoped correctly, no change needed there.timeout=5on the Graphite request inopenlibrary/core/admin.py— reasonable, in scope.style="width:150px;height:60px;"on each#{id}-graphdiv into a shared.chart-graphrule instatic/css/components/home.css.#chartLabelA,plot_tooltip_graph()inopenlibrary/plugins/openlibrary/js/graphs/plot.js) rendered behind the chart because they were missingz-index, unlike the equivalent tooltip inloadEditionsGraph()in the same file (which already setsz-index: 100). Root cause confirmed in a real browser:<main>hasposition: relative; z-index: 1, which establishes a stacking context that sits above anyz-index:autosibling appended later to<body>, regardless of DOM order — explains why the tooltip (appended last, no z-index) rendered underneath. Settingz-index: 100(mirroringloadEditionsGraph's existing tooltip) fixes it.Diff after the follow-up commit is now just 4 files / ~26 insertions, ~15 deletions net:
(
openlibrary/templates/admin/index.htmlneeded no changes — already scoped correctly.)How it was tested
make test(Python + JS unit + i18n) green; targetedpytest openlibrary/plugins/openlibrary/tests/test_home.py openlibrary/tests/test_templates.pygreen (746 passed);mypyclean;ruff/ruff-format/stylelint/eslint/codespellall clean viapre-commit.z-index: 100, confirmed viagetComputedStyle), console clean (aside from a pre-existing, unrelated dev-environment Solr/LazyCarousel 500 that reproduces on master too, since the local Solr index is empty).$ifgate would omit (the visitors.statschartblock + itsgraph-json-visitors-graphscript tag) to exercise the real client bundle against that DOM. Result: visitors chart cleanly absent, the other 4 charts render unchanged (same 110px row height, no layout shift), their tooltips still work and still render above the chart, console clean.HTTP 200, confirmed via code/diff review thatcounts["visitors"].get_summary(28)gates the same<h2>+<img>block master renders unconditionally (no JS/tooltip attached to this element, so the risk surface is much smaller than the homepage change). Not independently verified with an authenticated in-browser check —/adminrequires an admin-permissioned account and this dev sandbox doesn't have one readily available. Flagging this explicitly rather than silently skipping it, per this repo's review process.pa11yagainst the homepage; 6 pre-existing violations found, none related to the changed elements (header login link contrast, book-preview iframe title, colorbox button names) — no new violations introduced.(Note: the two screenshots above are Sadashii's original ones. I captured fresh Playwright screenshots for the follow-up commit — including the tooltip-above-chart fix and the layout with visitors hidden — but couldn't attach them here: there's no
gh/API path for uploading images to a PR comment from the CLI, only the web UI's drag-and-drop. Happy to hand them off if there's a preferred way to get them attached.)Stakeholders
@mekarpeles