Skip to content

Alex/fix attendance bug#358

Merged
alexsapps merged 3 commits intomainfrom
alex/fix-attendance-bug
May 3, 2026
Merged

Alex/fix attendance bug#358
alexsapps merged 3 commits intomainfrom
alex/fix-attendance-bug

Conversation

@alexsapps
Copy link
Copy Markdown
Collaborator

@alexsapps alexsapps commented May 3, 2026

Summary by CodeRabbit

  • New Features
    • Activist registry data is now scoped per chapter. Each chapter maintains its own separate activist data set. When switching chapters, you will see activists relevant to your current chapter only.

@alexsapps alexsapps marked this pull request as ready for review May 3, 2026 03:57
@alexsapps alexsapps requested a review from jakehobbs as a code owner May 3, 2026 03:57
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@alexsapps has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 3 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 69a16ecc-7dbe-4b40-bb18-62135c4af61e

📥 Commits

Reviewing files that changed from the base of the PR and between f1cff81 and a37edbc.

📒 Files selected for processing (5)
  • frontend-v2/src/app/(authed)/events/activist-storage.ts
  • frontend-v2/src/app/(authed)/events/event-form.tsx
  • frontend-v2/src/app/(authed)/events/events-page.tsx
  • frontend-v2/src/app/(authed)/events/useActivistRegistry.ts
  • frontend-v2/src/components/nav.tsx
📝 Walkthrough

Walkthrough

This PR converts activist data storage from a single global singleton to per-chapter database instances. The ActivistStorage class now accepts a chapterId parameter and maintains separate IndexedDB databases per chapter. A new getActivistStorage(chapterId) factory function caches instances by chapter. Consumers (event form, events page, and the activist registry hook) are updated to pass user.ChapterID to the hook, which then loads from the chapter-scoped storage.

Changes

Chapter-Scoped Activist Storage

Layer / File(s) Summary
Data Architecture
frontend-v2/src/app/(authed)/events/activist-storage.ts
ActivistStorage constructor now accepts chapterId and builds dbName as activist-registry-${chapterId}, creating separate databases per chapter instead of a singleton.
Factory & Caching
frontend-v2/src/app/(authed)/events/activist-storage.ts
New getActivistStorage(chapterId) function replaces the singleton, caching instances in a Map<number, ActivistStorage> keyed by chapter.
Hook Integration
frontend-v2/src/app/(authed)/events/useActivistRegistry.ts
useActivistRegistry now accepts chapterId parameter and calls getActivistStorage(chapterId) on mount to load and sync chapter-specific activist data.
Consumer Wiring
frontend-v2/src/app/(authed)/events/event-form.tsx, frontend-v2/src/app/(authed)/events/events-page.tsx
Event form and events page now retrieve user.ChapterID (via useAuthedPageContext in events-page) and pass it to useActivistRegistry for chapter-scoped filtering.
Cache Cleanup
frontend-v2/src/components/nav.tsx
Removed useQueryClient import and deleted queryClient.invalidateQueries() call before chapter-switch redirect, as cache invalidation is now handled differently in the per-chapter storage model.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fix: minor improvements to event attendance #310: Both PRs modify the activist storage/registry wiring; the main PR scopes storage per chapter via getActivistStorage(chapterId), while the related PR changes ActivistRegistry to accept storage instances, affecting the same files and initialization paths.
  • fix: fix bugs in event attendance page #309: Both PRs modify the activist storage and registry layers (activist-storage.ts and useActivistRegistry.ts); the main PR's per-chapter database scoping complements the related PR's storage and schema changes.

Suggested reviewers

  • jakehobbs

Poem

🐰 Storage maps by chapter grow,
No more singletons in a row!
Each activist cached, per-ID stored,
The form and page now chapter-floored.
Hops merrily through indexed blooms 🌰

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Alex/fix attendance bug' is vague and generic. While it mentions fixing an attendance bug, the actual changeset implements chapter-scoped activist data storage across multiple components, which is a broader architectural change than what the title suggests. Clarify the title to reflect the main architectural change, such as 'Make activist storage chapter-scoped' or 'Implement per-chapter activist registry caching'. The title should match the actual scope of changes shown in the PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alex/fix-attendance-bug

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 3 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend-v2/src/app/(authed)/events/useActivistRegistry.ts (1)

22-61: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

chapterId is missing from the useEffect dependency array — pnpm lint will fail.

chapterId is a hook parameter (not a ref or stable value) used on line 25, so react-hooks/exhaustive-deps requires it in the dependency array. Omitting it causes a lint error that would fail the CI/lint step called out in the coding guidelines.

Since chapterId is stable within a session (chapter switching triggers window.location.href, a full-page reload), the fix is to document the invariant with an eslint-disable comment, consistent with the existing pattern on line 94:

🛠️ Proposed fix
-  }, [])
+  // eslint-disable-next-line react-hooks/exhaustive-deps -- chapterId is stable within a session; chapter switches trigger a full page reload
+  }, [])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend-v2/src/app/`(authed)/events/useActivistRegistry.ts around lines 22 -
61, The useEffect depends on chapterId (used in getActivistStorage(chapterId))
but it's omitted from the dependency array causing a lint failure; update the
effect to explicitly acknowledge the stability of chapterId by adding an
eslint-disable comment for react-hooks/exhaustive-deps above the useEffect
(matching the existing pattern used elsewhere) so the hook remains unchanged,
e.g., place a single-line eslint-disable-next-line react-hooks/exhaustive-deps
comment immediately before the useEffect that references chapterId and leave the
body using getActivistStorage, registryRef.current.loadFromStorage, and
setIsStorageLoaded as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@frontend-v2/src/app/`(authed)/events/useActivistRegistry.ts:
- Around line 22-61: The useEffect depends on chapterId (used in
getActivistStorage(chapterId)) but it's omitted from the dependency array
causing a lint failure; update the effect to explicitly acknowledge the
stability of chapterId by adding an eslint-disable comment for
react-hooks/exhaustive-deps above the useEffect (matching the existing pattern
used elsewhere) so the hook remains unchanged, e.g., place a single-line
eslint-disable-next-line react-hooks/exhaustive-deps comment immediately before
the useEffect that references chapterId and leave the body using
getActivistStorage, registryRef.current.loadFromStorage, and setIsStorageLoaded
as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 52b61bf4-31fa-47a6-8044-8a7b72611b82

📥 Commits

Reviewing files that changed from the base of the PR and between ebcb290 and f1cff81.

📒 Files selected for processing (5)
  • frontend-v2/src/app/(authed)/events/activist-storage.ts
  • frontend-v2/src/app/(authed)/events/event-form.tsx
  • frontend-v2/src/app/(authed)/events/events-page.tsx
  • frontend-v2/src/app/(authed)/events/useActivistRegistry.ts
  • frontend-v2/src/components/nav.tsx

alexsapps added 3 commits May 3, 2026 04:14
The cache of activist names for attendance autofill mixed data from
different chapters and shared one last-sync timestamp meaning many
names would not get synced when switching chapters.

This change makes caches per-chapter to fix this issue and keep chapter
databases isolated from each other.
fixed by removing invalidateQueries before chapter switch navigation.

Calling queryClient.invalidateQueries() immediately before window.location.href
triggered React Query to fire refetch requests carrying the old session cookie.
Each refetch response included a Set-Cookie header (written by renewAuthSession
on the server) resetting the chapter back to the previous value. If those responses
arrived after the chapter-switch redirect chain had already set the new chapter
cookie, they would silently overwrite it — a non-deterministic race.

Since window.location.href causes a full page reload, React Query's in-memory
cache is discarded automatically; the invalidateQueries call was both redundant
and the source of the race.
This avoids scoping the database to just activists in case we want to
use it for other purposes, avoiding a combinatoric blowup of databases
from crossing chapter IDs with entity types.
@alexsapps alexsapps force-pushed the alex/fix-attendance-bug branch from 49828ef to a37edbc Compare May 3, 2026 04:14
@alexsapps alexsapps merged commit 2020c50 into main May 3, 2026
2 checks passed
@alexsapps alexsapps deleted the alex/fix-attendance-bug branch May 3, 2026 04:21
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