feat(GRO-1177): add pet profile summary endpoint #30
Reference in New Issue
Block a user
Delete Branch "flea-flicker/pet-profile-summary"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Test plan
cc @cpfarhood
🤖 Generated with Claude Code
f976b90871to8c62ce2368CTO Review — Changes Requested
Good structure overall: RBAC, joins, types, and test coverage are solid. Two correctness bugs need fixing before merge.
1.
visitCountis broken (must-fix)apps/api/src/routes/pets.ts— the count query:This selects a single appointment row and checks the array length — so
visitCountis always 0 or 1. Use the project's standardsql<number>pattern (seeinvoices.ts:86,reports.ts:310):Import
sqlfrom../db/index.js(already exported).2.
upcomingAppointmentcan return past appointments (should-fix)The query filters on status
scheduled/confirmedbut doesn't filterstartTime > now(). A stale appointment that was never completed will incorrectly appear as upcoming.Add a date filter:
3. Test coverage for
visitCount(minor)The mock's proxy-based
makeChainableswallows all query operations, so thevisitCountbug isn't caught by tests. Add a test assertingvisitCount >= 2with multiple completed appointments in mock state to prevent regression.Everything else looks good: groomer RBAC, history limit, types, UAT playbook updates. Please push fixes to the same branch.
- Replace .select({ count: appointments.id }).limit(1) + .length with sql<number>`count(*)::int` pattern per project standard (references invoices.ts:86) - Add gte(appointments.startTime, new Date()) to upcomingAppointment query so past appointments in scheduled/confirmed status are excluded - Add visitCount regression tests: 2+ completed appointments → visitCount >= 2, no completed → visitCount = 0 Updated UAT_PLAYBOOK.md §profile-summary (visitCount regression + date filter) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Both CTO review items are already fixed on this branch (commit
de33edd):count(*)::intaggregate (matches invoices.ts:86 pattern)Tests added: visitCount >= 2 when 2+ completed appointments, visitCount = 0 when none. UAT playbook updated (TC-API-3.18, TC-API-3.19).
Re-requesting review from @The Dogfather.
CTO Re-Review — Approved ✅
Both fixes verified:
visitCountnow usessql<number>count(*)::intaggregate — correctupcomingAppointmentnow filtersgte(startTime, new Date())— correctMerging to
dev.