Repository navigation
Conversation
Each was a single-column index on the leading column of a unique index or constraint on the same table, which already serves those lookups. They only added a write per insert and update.
event.current_check_ins, hackathon_team.current_members and hackathon.current_participants were running counters. FK cascades (deleting a user, deleting a team) removed the rows they counted without touching them, so they drifted and the capacity checks that read them could refuse real people. Capacity checks now count the child rows under the same parent-row lock, and every read derives the number with one grouped query per list. joinTeam now takes that lock too. The columns stay, unread and unwritten, until a later change drops them. A real-database test (gated on TEST_DATABASE_URL, set in CI) sets the stored counters wrong on purpose and checks every count follows the rows.
Feature: refactor/db-integrity-a to dev
Contributor
Author
Contributor
Author
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
Author
|
Visit the preview URL for this PR (updated for commit 647dff0): https://hacklytics2027--pr-612-hjbcnvxj.web.app (expires Sat, 21 Nov 2026 22:22:39 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c48ba34db61581e25fe2978355160b5eefe0e83f |
Contributor
Author
|
Visit the preview URL for this PR (updated for commit 647dff0): https://hacklyticss2026--pr-612-lfib7418.web.app (expires Sat, 21 Nov 2026 22:22:38 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 5d238be33273095766c18a8339b7b0c47de8a950 |
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.
Automated PR tracking changes from
devintomain.Note
Medium Risk
Touches concurrency-sensitive capacity checks for events, hackathon seats, and team rosters; behavior should be more correct but any locking/counting bugs could admit or refuse people incorrectly.
Overview
Replaces stored counters (
events.current_check_ins,hackathon_teams.current_members,hackathons.current_participants) with live counts from child rows, fixing drift when cascades or deletes did not update the columns (columns stay in the DB for now but are no longer read or written).A new
derived-countsservice batches groupedcount(*)queries and merge helpers. Event check-in capacity locks the event row and countsevent_check_inrows instead of incrementing a counter; hackathon acceptance dropssyncCurrentParticipantsand relies onassertSeatsplus derived reads; team join/leave counts participants under a team lock and stops updatingcurrent_members. List/detail paths (events, hackathons, teams, bootcamp admin, public/events) return the derived numbers.CI sets
TEST_DATABASE_URLand addsderived-counts.db.test.tsagainst real Postgres; mocks and docs are updated to match.Reviewed by Cursor Bugbot for commit 647dff0. Bugbot is set up for automated code reviews on this repo. Configure here.