fix(body): preserve timestamp range type - #2334
Conversation
Filter native DateTime64 values before projecting serialized timestamps so ClickHouse aliases cannot rebind range predicates to String.\n\nRefs #2294
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideAdjust BodyRepository.listRange() to filter ClickHouse native timestamps in a subquery before string serialization, and add tests and documentation to cover timezone-range behavior and prevent alias collisions. Sequence diagram for BodyRepository.listRange ClickHouse timestamp filteringsequenceDiagram
actor Client
participant BodyRepository
participant BodyClickHouseStore as BodyClickHouseStore
participant ClickHouse
Client->>BodyRepository: listRange(startDate, endDate)
BodyRepository->>BodyClickHouseStore: query(listRange SQL)
BodyClickHouseStore->>ClickHouse: execute(listRange SQL)
Note over ClickHouse: Inner body_measurements subquery
ClickHouse-->>ClickHouse: toTimeZone(recorded_at, timezone)
ClickHouse-->>ClickHouse: toDate(toTimeZone(...)) range filter
Note over ClickHouse: Outer projection
ClickHouse-->>ClickHouse: toString(body_measurements.recorded_at)
ClickHouse-->>BodyClickHouseStore: filtered and serialized rows
BodyClickHouseStore-->>BodyRepository: rows
BodyRepository-->>Client: BodyMeasurement[]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Storybook previews for This comment updates automatically on each PR push. |
|
LGTM! The subquery refactoring in 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
PR Summary by QodoFix BodyRepository.listRange by filtering DateTime64 before string projection
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
168 rules✅ Skills:
fix-provider, write-tests, cloudflare 1. Backfill-heavy ClickHouse test setup
|
Summary
recorded_atis still a nativeClickHouse
DateTime64a Los Angeles midnight boundary
Root cause
BodyRepository.listRange()projectedtoString(recorded_at) AS recorded_atin the same query scope where
WHEREpassedrecorded_attotoTimeZone.ClickHouse rebound that identifier to the projected
Stringalias, producingIllegal type String of argument of function toTimezone.Validation
pnpm vitest run --project unit packages/server/src/repositories/body-repository.test.ts(16 passed)
pnpm tsc --noEmitpassedgit diff --checkpasseddbt project but then stalled under the same host I/O pressure
(
beforeAlltimed out at 120 seconds); hosted integration is the requiredreal-engine red/green gate before this PR leaves draft
Fixes #2294
Summary by Sourcery
Fix body metrics range queries to filter on native ClickHouse timestamps before string serialization, preventing timezone alias type errors and ensuring correct local-date ranges.
Bug Fixes:
Enhancements:
Documentation:
Tests:
Summary by cubic
Fix body metrics range filtering by applying the date filter to native ClickHouse
DateTime64values and only stringifying after, preventing timezone alias type errors and returning correct inclusive local-date results. Fixes #2294.Bug Fixes
BodyRepository.listRange()to filter in an inner subquery on nativerecorded_at, then serialize in the outer projection; orders by the innerrecorded_atto avoid alias rebound errors.Tests
analytics.v_body_measurementbefore asserting exact local-date filtering.packages/server/src/repositories/body-repository.test.ts.docs/superpowers/plans/2026-07-29-body-metrics-timezone-filter.md.Written for commit e4f1dfd. Summary will update on new commits.