Conversation
"Send 3 Emails" then one email sent, which is what Equal-Vote#1287 reports. Both sides apply the same filter; they apply it to different snapshots. The dialog counts `electionRoll`, an array fetched once when the Voters page mounts (`useGetRolls` in a `useEffect` with an empty dependency list, so it is refetched only after editing a voter or clearing the list). The backend re-queries the roll at send time and filters again (`sendEmailController.ts`). Any ballot cast between page load and pressing the button makes the number on the button wrong. Two changes: - Opening "Draft Email Blast" refetches the roll, so the count is of the same rows the backend is about to select. - The button is disabled when the count is zero. Previously "Send N Emails" with a stale N could be pressed against an empty target, and the backend answered with a 400 ("All voters have voted") — an error message for a situation the UI should not have offered in the first place. The reporter suggested dropping the number instead; @ArendPeter's reply says the count is worth keeping for confidence that the filter is right, so this keeps it and makes it true. Not covered here: a roll whose email is blank or undeliverable is still counted and still queued — that is a SendGrid delivery matter rather than a count mismatch, and the issue does not ask about it.
|
Warning Review limit reached
Next review available in: 59 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for bettervoting ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Description
Closes #1287 — "The button said 'Send 3 emails' even though 2 of the 3 voters had already voted … only 1 email was sent (which is correct)".
Both sides apply the same filter. They apply it to different snapshots.
electionRoll, an array fetched once when the Voters page mounts —useGetRollsin auseEffectwith an empty dependency list, refetched only after editing a voter or clearing the listsendEmailControllerre-queries the roll at send time and filters againSo any ballot cast between page load and pressing the button makes the number wrong. That is exactly the reported scenario, and it needs no SendGrid access to see — it is two snapshots of one table.
Two changes
The reporter suggested dropping the number instead; @ArendPeter's reply says the count is worth keeping "to give myself confidence that I'm filtering it properly". This keeps it and makes it true.
Not in scope
A roll whose email is blank or undeliverable is still counted and still queued. That is a delivery concern rather than a count mismatch, and the issue does not ask about it.
There is no test coverage of recipient selection at all — no backend test touches
sendEmails, and no Playwright spec opens this dialog. Worth adding, but it needs a fixture with a partly-voted roll, which is more than this fix.Related Issues
Closes #1287