Unify attendee dependent-row purges across single and orphan paths - #1821
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe change centralizes dependent-row deletion SQL for attendee purges, reuses it for orphan-attendee cleanup, adds orphan counting, and expands tests to verify system-note removal. ChangesAttendee purge behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
stefan-burke
enabled auto-merge
July 14, 2026 18:18
This was referenced Jul 15, 2026
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.
Before this change, the single-attendee delete path (in
deleteAttendee) and the orphan-attendee purge path maintained two separate lists of the tables that link to an attendee. They had drifted: the orphan list was missingservice_costsand handled it with a separate hand-written statement, while the single-delete path carried the full five-table list inline. Two parallel implementations of the same "delete an attendee's dependent rows" step is exactly the kind of duplication the project avoids.What changed
I extracted one shared list of dependent-row targets and one helper that builds the delete statements for any set of attendee ids:
DEPENDENT_ROW_TARGETSinsrc/shared/db/attendees/delete.tslists all five tables with their linking column:processed_payments,attendee_answers,listing_attendees,system_notes(all keyed byattendee_id), andservice_costs(keyed byservicing_attendee_id).attendeeDependentDeleteStatements(attendeeIds)builds theDELETE FROM ... WHERE ... IN (...)statements for that list, taking a single{ sql, args }so the same helper works for one id ({ sql: "?", args: [id] }) and for the orphan subquery ({ sql: ORPHAN_IDS, args: [cutoffIso] }).The single-attendee purge now calls this helper with a single-id statement; the orphan purge calls it with the orphan-id subquery. The orphan path's separate
ORPHAN_DEPENDENT_TABLESlist and its hand-writtenservice_costsdelete are gone — there is now one place that decides which dependent rows get cleared, used by both paths.What stayed the same
The actual SQL behaviour is unchanged. A single-id delete was previously
WHERE field = ?and is nowWHERE field IN (?); for one bound value these are equivalent. The orphan subquery deletes keep the sameORPHAN_IDSsubselect and the same cutoff binding, so the same rows are swept in the same order.service_costsis now swept by the orphan purge through the same shared list instead of a separate statement — so the orphan path gains exact parity with the single-delete path rather than the near-miss it had before.Tests
The orphan-attendee test now seeds a
system_notesrow for an orphan and asserts it is cleared alongside the answer and payment rows, locking in that the shared helper covers all five tables for the orphan path too.A separate servicing edge-case test had comments referring to the now-removed
ORPHAN_DEPENDENT_TABLESconstant; I updated those to point at the shared mechanism so nothing references a deleted symbol.Summary by CodeRabbit
Bug Fixes
Tests