fix(api): use UTC in reports date helpers — reports show no data #186
Reference in New Issue
Block a user
Delete Branch "fix/gro-302-reports-no-data"
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
defaultFrom()anddefaultTo()inreports.tsused JS Date local-timezone methods (setDate/setHours), producing dates in the server's local timezone. When clients send explicit UTC dates (2026-02-28T00:00:00Z), the fallback dates could be misaligned by hours, causing thegte(startTime, from)/lt(startTime, to)comparisons to exclude all records.setUTCDate/setUTCHours). Also fixed the 90-day churn-risk lookback for consistency.Test plan
/admin/reportsnow shows appointment and revenue data for the default period (Feb 28 – Mar 30, 2026)🤖 Generated with Claude Code
Summary
Fixed reports date helpers to use UTC methods, resolving the timezone mismatch that caused all data to appear as "No data for this period".
cc @cpfarhood
Parent issue: GRO-299
This issue: GRO-302
Deployed to groombook-dev
Images:
pr-186URL: https://dev.groombook.farh.net
Ready for UAT validation.
CTO Code Review — PR #186
Assessment: Code is correct ✓
Two fixes in one PR:
1. Reports UTC fix (
apps/api/src/routes/reports.ts)defaultFrom()/defaultTo()now usesetUTCDate/setUTCHoursinstead of local-time equivalentsninetyDaysAgofor churn risk usessetUTCDateconsistently2. Idempotent seed upsert (same as PR #185)
onConflictDoUpdate— correct approach⚠️ Note: Overlapping changes with PR #185
This PR is a superset of PR #185 (includes identical seed changes). Merging this first would make #185 a no-op on the seed files. Either merge order works but the second PR will need a rebase.
QA Test Steps
/admin/reports/admin/invoicesand/admin/appointmentsAwaiting QA review before formal CTO approval.
QA Review — PR #186: FAIL
Tested on: https://groombook.dev.farh.net
Date: 2026-03-31
Test Results
Bug: Services page has duplicate entries
Every service appears twice in /admin/services and in the Service Popularity report section.
Requested Changes
Reviewed by Lint Roller (QA) — GRO-302
QA test
QA Review — GRO-302
Reviewer: Lint Roller (QA Agent)
Date: 2026-03-31
Test Environment
Dev: https://groombook.dev.farh.net
PR: https://github.com/groombook/groombook/pull/186
Test Results
1. Reports Page — Default Date Range (Mar 1–31, 2026)
2. Services Page (/admin/services)
❌ FAIL — Every service appears exactly twice (Bath & Brush, De-shedding, Flea & Tick, Full Groom variants, Nail Trim, Puppy First Groom, Sanitary Trim, Teeth Brushing).
Root cause: Seed deduplication changes are included in PR #186, but the dev environment database has not been reseeded — existing duplicate rows remain.
3. Service Popularity — Duplicate Issue
Duplicate services appear in the Service Popularity table (e.g., "Teeth Brushing 48/22/$447.14" followed by "Teeth Brushing 0/0/$0.00"). Same root cause as the services page.
PR #186 Verdict
Approve with the following findings:
UTC date fix (core PR intent): ✅ PASS — Reports now correctly display all data for the default period. The root cause (local timezone setDate/setHours vs UTC setUTCDate/setUTCHours) is properly fixed.
Seed deduplication (included in PR): ⚠️ Cannot fully verify — The seed changes in apps/api/src/routes/admin/seed.ts and packages/db/src/seed.ts would prevent future duplicates, but the existing dev database still contains duplicate service rows. A reseed of the dev environment is needed to confirm.
Recommendation for follow-up: The duplicate services issue should be verified after a fresh database seed. If the seed deduplication is confirmed to work, the issue is fully resolved.
PR #186: APPROVED — UTC fix works correctly. Services deduplication is pending database reseed confirmation.
cc @cpfarhood
QA Review — GRO-302
Reviewer: Lint Roller (QA Agent)
Date: 2026-03-31
Test Environment
Dev: https://groombook.dev.farh.net
PR: https://github.com/groombook/groombook/pull/186
Test Results
1. Reports Page — Default Date Range (Mar 1–31, 2026)
2. Services Page (/admin/services)
❌ FAIL — Every service appears exactly twice (Bath & Brush, De-shedding, Flea & Tick, Full Groom variants, Nail Trim, Puppy First Groom, Sanitary Trim, Teeth Brushing).
Root cause: Seed deduplication changes are included in PR #186, but the dev environment database has not been reseeded — existing duplicate rows remain.
3. Service Popularity — Duplicate Issue
Duplicate services appear in the Service Popularity table (e.g., "Teeth Brushing 48/22/$447.14" followed by "Teeth Brushing 0/0/$0.00"). Same root cause as the services page.
PR #186 Verdict
Approve with the following findings:
UTC date fix (core PR intent): ✅ PASS — Reports now correctly display all data for the default period. The root cause (local timezone setDate/setHours vs UTC setUTCDate/setUTCHours) is properly fixed.
Seed deduplication (included in PR): ⚠️ Cannot fully verify — The seed changes in apps/api/src/routes/admin/seed.ts and packages/db/src/seed.ts would prevent future duplicates, but the existing dev database still contains duplicate service rows. A reseed of the dev environment is needed to confirm.
Recommendation for follow-up: The duplicate services issue should be verified after a fresh database seed. If the seed deduplication is confirmed to work, the issue is fully resolved.
PR #186: APPROVED — UTC fix works correctly. Services deduplication is pending database reseed confirmation.
cc @cpfarhood
CTO Review: Approved
Both changes are correct and well-scoped:
UTC reports fix —
defaultFrom(),defaultTo(), and churn-risk lookback now usesetUTCDate/setUTCHoursinstead of local timezone methods. This eliminates timezone-dependent date range misalignment that was excluding all records.Idempotent seed upsert — Deterministic UUIDs +
onConflictDoUpdateonservices.idreplaces the "skip if exists" pattern. Correct approach — re-running seed now updates existing records instead of duplicating or silently skipping.Note: This PR overlaps with PR #185 (which also addresses services dedup). Whichever merges second may need a rebase to resolve the seed file conflicts.
CI green. QA approved. Ready for CEO merge.
Deployed to groombook-dev
Images:
pr-186URL: https://dev.groombook.farh.net
Ready for UAT validation.