Gate page-count and publish-year banners on per-stat pending flags#104
Merged
Conversation
The "Still enriching" banner on Total Pages Read, Average Book Length, and Average Book Age was driven by the global enrichment.pending flag, which stays true until every book has been API-checked. Goodreads CSVs supply both fields per row, so those banners showed throughout enrichment even though the values were already final. Add length_pending / year_pending flags computed from actual missing data (any book with NULL page_count / publish_year) and gate the three affected banners on those instead. Other stats (genres, fiction split, mainstream score) still use the global flag — they genuinely depend on enrichment.
…ia Alpine Address review feedback on top of the per-stat banner change: - Parameterize enrichment_banner.html with `condition` (required) and `store_key` (optional, default "pending") so all 5 callers share one source of truth instead of inlining. - Bind opacity-60 wrapper via Alpine `:class` (in addition to server-side rendering for FOUC) so dimming clears live mid-poll without waiting for the page reload. - Bind banner `x-show` to per-stat Alpine store keys so the cross-flag asymmetry between server gate and live binding is gone. - Update Alpine store init + poll() to seed and update per-stat flags. - Rename length_pending → pages_any_missing, year_pending → year_any_missing to disambiguate from the existing pages_pending (50%-done sparseness threshold for skeletons).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The "Still enriching" banner showed up on stats that didn't actually need enrichment for users uploading Goodreads CSVs (which include
Number of PagesandOriginal Publication Yearper row).Root cause: a single global
enrichment.pendingflag (Count(google_books_last_checked NOT NULL) < total) gated banners on three stats whose values were already final from the CSV — Total Pages Read, Average Book Length, and Average Book Age.Fix
Added two per-stat flags to
_compute_enrichment_progress:length_pending— true iff any book haspage_count IS NULLyear_pending— true iff any book haspublish_year IS NULLThe three affected banners now gate on these flags instead of the global one. Genre/fiction-split/mainstream banners still use the global flag because they genuinely depend on enrichment-derived data.
The Alpine
x-show="$store.enrichment?.pending"binding stays on the inline banners so they vanish the moment global enrichment finishes (instead of waiting for the page reload).Behaviour
Test plan
EnrichmentCompletionDetectionTestscovering both flags True/Falsecore.tests.test_views_e2e+core.tests.test_storygraph_integration(27 tests) all passcsv/test-csvs/goodreads_alien_batch3.csv, confirm Total Pages Read / Avg Book Length / Avg Book Age don't show "Still enriching"