fix(api): repair root src/routes/pets.ts visit-count query (GRO-1945) #107

Merged
Flea Flicker merged 1 commits from flea/GRO-1945-pets-visitcount-hotfix into dev 2026-05-30 03:24:03 +00:00
Member

Summary

Fixes TS2339 error in src/routes/pets.ts:156 that was blocking all Docker builds on dev.

Root cause: The profile-summary route used select({ count: appointments.id }) with .limit(1), which under noUncheckedIndexedAccess produces T | undefined — destructuring { count } from undefined is a type error.

Fix: Replaced with sql\count(*)::int`(matching the correctapps/api/src/routes/pets.ts:365), imported sqlfrom@groombook/db, and used countRow?.count ?? 0` for null-safety.

Changes

  • src/routes/pets.ts: Added sql to @groombook/db import
  • src/routes/pets.ts:156-161: Replaced broken visit-count query with correct count(*)::int version
  • src/routes/pets.ts:199: Changed Number(count ?? 0)visitCount

Testing

CI includes Lint+Typecheck and Test; Docker Build& Push stage now passes (previously blocked by TS2339).


🤖 Generated with Claude Code

## Summary Fixes TS2339 error in `src/routes/pets.ts:156` that was blocking all Docker builds on `dev`. **Root cause:** The `profile-summary` route used `select({ count: appointments.id })` with `.limit(1)`, which under `noUncheckedIndexedAccess` produces `T | undefined` — destructuring `{ count }` from `undefined` is a type error. **Fix:** Replaced with `sql\`count(*)::int\`` (matching the correct `apps/api/src/routes/pets.ts:365`), imported `sql` from `@groombook/db`, and used `countRow?.count ?? 0` for null-safety. ## Changes - `src/routes/pets.ts`: Added `sql` to `@groombook/db` import - `src/routes/pets.ts:156-161`: Replaced broken visit-count query with correct `count(*)::int` version - `src/routes/pets.ts:199`: Changed `Number(count ?? 0)` → `visitCount` ## Testing CI includes Lint+Typecheck and Test; Docker Build& Push stage now passes (previously blocked by TS2339). --- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Dogfather added 1 commit 2026-05-30 03:22:20 +00:00
fix(api): repair root src/routes/pets.ts visit-count query (GRO-1945)
CI / Test (pull_request) Successful in 11s
CI / Lint & Typecheck (pull_request) Successful in 14s
CI / Build & Push Docker Images (pull_request) Successful in 1m4s
a14bb5e17d
Use sql\`count(*)::int\` instead of selecting appointments.id, which was
causing TS2339 under noUncheckedIndexedAccess (arr[0] is T | undefined).

Import sql from @groombook/db. Use countRow?.count ?? 0 to stay
noUncheckedIndexedAccess-safe.

Matches the working implementation in apps/api/src/routes/pets.ts:365.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Flea Flicker merged commit 981a257d2d into dev 2026-05-30 03:24:03 +00:00
Sign in to join this conversation.