feat(analytics): date-range drill scope for granularity-bucketed date dimensions (#1752)#3256
Merged
Merged
Conversation
… dimensions (#1752) A report/dashboard cell grouped by a `dateGranularity` date dimension ("2026-Q2") covers a SPAN of records, so drilling it needs a range (>= start AND < nextStart), which the equality drill contract (drillRawRows) can't express — date dims were excluded from drill metadata, so a drill landed on an unscoped superset. - core: add `bucketKeyToCalendarRange(key, granularity)`, the inverse of `bucketDateValue` — canonical bucket key → half-open [start, end) YYYY-MM-DD span. Pure, tz-naive calendar math; null for unbucketable/out-of-range keys. - service-analytics: emit a `drillRanges` sidecar (row-aligned, the range companion to drillRawRows) for date+granularity dims from the canonical key in the pre-label snapshot pass. datetime under a non-UTC tz is omitted (superset) until instant bounds land; a tz-naive date field is exact under any tz (ADR-0053). Round-trip parity test pins bucketKeyToCalendarRange to bucketDateValue. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RCXBnmMQTwjmFkjtpEe11f
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 3 package(s): 31 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 19, 2026 07:03
This was referenced Jul 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Closes the framework half of #1752. A report/dashboard cell grouped by a
dateGranularitydate dimension ("2026-Q2") covers a span of records, so drilling it needs a range (>= start AND < nextStart) — which the equality drill contract (drillRawRows) can't express. Date dims were therefore excluded from drill metadata entirely, so a drill landed on an unscoped superset (all time buckets).What
@objectstack/core— addbucketKeyToCalendarRange(key, granularity), the inverse ofbucketDateValue: a canonical bucket key → its half-open[start, end)calendar span asYYYY-MM-DD(endexclusive, i.e. the next bucket's first day). Pure, timezone-naive calendar arithmetic; returnsnullfor the null bucket or a shape-valid-but-out-of-range key (2026-13,2025-W53,2026-02-30) so callers fall back to a superset drill rather than emit a wrong bound.@objectstack/service-analytics— emit adrillRangessidecar (row-aligned; the range companion todrillRawRows) fordate+dateGranularitydimensions, computed from the canonical bucket key in the pre-label-resolution snapshot pass (before labels overwrite the raw grouped value). Also setsobjectfor time-only reports so the host can open the list.Design decisions
bucketDateValue) and native-SQL (buildDateBucketExpr) paths and is always available at output time — no raw-instant retention, works uniformly for both strategies. A round-trip test pins the inverse to the forward function.[gte, lt)enforced by the util; callers never choose the operator (avoids the classic<=boundary double-count).dateis a tz-naive calendar day →YYYY-MM-DDbounds are exact under any reference timezone. Adatetimebuckets on the reference tz's calendar; its boundaries are that tz's midnight instants, whichYYYY-MM-DDbounds capture only under UTC — so adatetimefield under a non-UTC reference tz is omitted (host drills a superset) until instant-boundary support lands. This never emits a half-right range (a regression vs. the honest superset).Testing
bucketKeyToCalendarRangeround-trip/parity + exact-boundary + rejection tests (49 cases, incl. ISO-week2024-12-30 → 2025-W01, leap2024-02-29, quarter/year rollover).drillRangesemission: quarter range, matrix "X by time" (equality dim + range side by side), datetime-non-UTC omission, date-non-UTC still emitted.@objectstack/service-analytics170/170,@objectstack/objectql1001/1001. Source type-checks clean (DTS build).Follow-up
Consumed by the objectui report drill-through (companion PR on
objectstack-ai/objectui, same branch) which forwardsdrillRangesinto the drill drawer and the/databare-data-surface URL contract.🤖 Generated with Claude Code
https://claude.ai/code/session_01RCXBnmMQTwjmFkjtpEe11f
Generated by Claude Code