Skip to content

Remove dead collectionGroup fallback queries for BQ counts#52

Merged
tripledoublev merged 2 commits intofeat/ballot-questionsfrom
fix/remove-bq-count-fallback-queries
Apr 15, 2026
Merged

Remove dead collectionGroup fallback queries for BQ counts#52
tripledoublev merged 2 commits intofeat/ballot-questionsfrom
fix/remove-bq-count-fallback-queries

Conversation

@tripledoublev
Copy link
Copy Markdown
Member

@tripledoublev tripledoublev commented Apr 15, 2026

Summary

  • BallotQuestion docs now store testimonyCount, endorseCount, neutralCount, opposeCount with defaults of 0
  • Removes the collectionGroup fallback query functions (getBallotQuestionCounts, getBallotQuestionTestimonySummary) and their hasStored*/getStored* helpers — these were always bypassed once counts were stored on the doc
  • Reads counts directly from the BallotQuestion doc in both pages/ballotQuestions/index.tsx and pages/ballotQuestions/[id].tsx
  • Adds ?? 0 guards since api.ts does a raw Firestore cast without running the runtype defaults

Note for reviewer

I ran the backfill scripts needed to run on dev (and prod when shipping) in this order:

yarn firebase-admin run-script backfillTestimonyBallotQuestionId --env dev --creds <key>
yarn firebase-admin run-script backfillBallotQuestionTestimonyCounts --env dev --creds <key>

backfillTestimonyBallotQuestionId must run first so that legacy testimony docs have ballotQuestionId indexed before the count backfill reads them.

Test plan

  • Component tests pass: BallotQuestionDetails, BrowseBallotQuestions
  • /ballotQuestions renders without serialization errors
  • /ballotQuestions/[id] shows correct counts after backfill is run

Counts are now stored on BallotQuestion docs with defaults of 0,
so the hasStored/getStored helpers and live query fallbacks are
unreachable. Read counts directly from the doc.
@tripledoublev tripledoublev merged commit 89227cf into feat/ballot-questions Apr 15, 2026
8 checks passed
@tripledoublev tripledoublev deleted the fix/remove-bq-count-fallback-queries branch April 15, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant