Skip to content

Answer canRefund from the lines the page already loaded - #2093

Merged
stefan-burke merged 3 commits into
mainfrom
claude/answer-can-refund-from-loaded-lines
Aug 17, 2026
Merged

Answer canRefund from the lines the page already loaded#2093
stefan-burke merged 3 commits into
mainfrom
claude/answer-can-refund-from-loaded-lines

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Aug 17, 2026

Copy link
Copy Markdown
Member

Answer canRefund from the lines the page already loaded

Fourth of a short series of small changes that cut wasted database round trips, found by profiling real requests.

What was happening

The attendee page loads every one of that attendee's booking lines. Then, to decide whether to offer the Refund button, it asked the database again:

SELECT 1 FROM listing_attendees
 WHERE attendee_id = ? AND listing_id = ? AND quantity > 0 LIMIT 1

That question was already answered by the rows in hand.

The change

The decision reads the lines the page loaded rather than asking again. Both loads still run together, so this drops a round trip without making anything wait longer, and deciding whether a refund can be offered is now a small pure function over facts the page already holds.

The distinction the original query existed to protect is kept exactly. It checked the exact attendee-and-listing row rather than an arbitrary joined sibling, and excluded no-quantity placeholder lines, so a line marked no-quantity stops offering the refund. The in-memory check does the same: it looks for a line on that listing with a real quantity.

What it saves

One round trip on every attendee page load — the actions tab, the edit form, and every other tab, since they share this loader.

Tests

  • A new test records the statements the page load makes and asserts that existence query is not among them. It fails without the change (the query shows up) and passes with it.
  • The existing behaviour tests are unchanged and still pass, including the one that turns the refund off for a no-quantity line — the case the exact-row check exists for.
  • Re-verified across the attendee page and page-data suites (52 tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AXUnTqyoPzb4VPSsyLwk69


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved refund eligibility checks using existing attendee booking information.
    • Ensured payment references and booking details load efficiently when editing attendee records.
    • Prevented unnecessary duplicate booking-line queries during refund checks.

claude added 2 commits August 17, 2026 17:52
The attendee page loaded every one of the attendee's booking lines, then
asked the database again whether one of those same lines was a real
booking on the listing. The answer was already in hand.

Both loads still run together, so this drops a round trip without making
anything wait longer. The decision is now a pure function over facts the
page holds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXUnTqyoPzb4VPSsyLwk69
Fails without the change: the existence query shows up in the recorded
statements.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AXUnTqyoPzb4VPSsyLwk69
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 153c01c5-ac09-4105-bbf0-a2c2b6b1b1a1

📥 Commits

Reviewing files that changed from the base of the PR and between a8b2280 and 0eb9d14.

📒 Files selected for processing (2)
  • src/features/admin/attendee-page-data.ts
  • test/features/admin/attendee-page-data/refund-actions.test.ts

Included review availability: 1 review is currently available. Based on recent review activity, included reviews refill at 4 per hour.


📝 Walkthrough

Walkthrough

Refund eligibility now uses already-loaded attendee lines instead of a separate booking-line query. Payment references and attendee lines load in parallel. A regression test verifies that loadAttendeeForEdit does not issue the redundant query.

Changes

Attendee refund eligibility

Layer / File(s) Summary
Refund eligibility data loading
src/features/admin/attendee-page-data.ts, test/features/admin/attendee-page-data/refund-actions.test.ts
loadAttendeeForEdit loads payment references and attendee lines in parallel. canRefund requires complete payment references, remaining refund work, and a positive-quantity booking on the attendee’s listing. Tests record queries and verify that no redundant booking-line query runs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 0eb9d

The PR removes a redundant database round trip while preserving the refund decision for quantity-bearing lines; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes deriving canRefund from the attendee lines already loaded by the page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/answer-can-refund-from-loaded-lines
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/answer-can-refund-from-loaded-lines

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@stefan-burke
stefan-burke enabled auto-merge August 17, 2026 18:10
@stefan-burke
stefan-burke added this pull request to the merge queue Aug 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 17, 2026
@stefan-burke
stefan-burke added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit c71bd0c Aug 17, 2026
2 checks passed
@stefan-burke
stefan-burke deleted the claude/answer-can-refund-from-loaded-lines branch August 17, 2026 18:38
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.

2 participants