Repository navigation
fix(service-analytics): drop a compareTo bucket with no current-window counterpart - #37318
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu
…w counterpart Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 2b81a9a7dcf6db20a4fabb7d7374921d680ad955 && git checkout 2b81a9a7dcf6db20a4fabb7d7374921d680ad955
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d88c41e51d60224c286267657a2c328ce158eab1 bc2fbbea539dde5450891b68e5128ae8a0bc1368 && git checkout -B drift-repro d88c41e51d60224c286267657a2c328ce158eab1 && git merge --no-ff bc2fbbea539dde5450891b68e5128ae8a0bc1368
node scripts/docs-audit/affected-docs.mjs --json d88c41e51d60224c286267657a2c328ce158eab1 |
|
repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu
席位意见:ACCEPT,排队落地。 席位核对 — ACCEPT · head bc2fbbe (2026-11-25T15:50Z)
|
Requested by Alice · project thread
Fixes #36770
Clause-②: no
Metadata-protocol: none
维护者速读
仪表盘组件按周、按月画趋势并开启「和上一期对比」时,对比值不再错落到本期某一格上,也不再多出一根本期范围外的柱子(例如「本月按月」多出的十一月)。
为什么做:上一期比本期多切出一格时,那一格没有对应位置却保留了自己的日期,悄悄覆盖了本期第一周的对比数字,用户看到的对比是错的。
出错会怎样:只影响对比列;若判断有误,最坏是某一格的对比值显示为 0,可直接撤回本次改动恢复原样。
要你做的:无。
What changes
packages/services/service-analytics/src/dataset-executor.ts, compare pass ofrunCompare:alignedCompareBucketKeynow distinguishes its two "declined" answers.nullstill means "not a calendar position, leave the key alone" (the empty bucket, a raw timestamp, a key of another granularity). A key that IS a bucket of this granularity but whose shifted-back ordinal falls outside the current window now answers the new module-level sentinelNO_CURRENT_COUNTERPART.NO_CURRENT_COUNTERPARTinstead of keeping its own key. Before, that own key either named a current bucket the value was never aligned to (December 2026 by week: the previous period's own2026-W49, the single day 30 Nov, overwrote the comparison that2026-W44had aligned onto the current2026-W49) or appended a row outside the window (an extra2026-11row on "this month" by month, an extra2026-03row on Q2 2026 by month).NO_CURRENT_COUNTERPARTis not re-exported fromsrc/index.ts; the package's public surface is byte-unchanged (thedataset-compare-kind-refusalbarrel pin stays green).Tests
New top-level
describeinsrc/__tests__/dataset-compare-bucket-alignment.test.ts(the shared harness for this behaviour):bucketKeyToCalendarRange): W49..W53 carry W44..W48's values, W49 is not overwritten.2026-03row.Red first on
origin/maind88c41e (pin commit 8c2bcea, fix not yet applied): 3 failed / 1 passed. W49 readopp_count__compare: 4900where 4400 was expected; the month and quarter cases each carried an extra out-of-window row (2026-11,2026-03).Fixture triage (three pins encoded the removed fallback):
dataset-compare-bucket-alignment.test.tsunit pins: the outside-window cases now expectNO_CURRENT_COUNTERPARTinstead ofnull.2026-06on both passes) pinned exactly the removed branch. Replaced by the collision in its smallest form: that key has no counterpart and June readsopp_count__compare: 0.dataset-selection-window.test.ts"buckets the compareTo pass identically": its fake now answers each pass in the window it filtered to (June, then May). What it pins (both passes resolve the same GROUP BY granularity) is unchanged, and so is its assertion.Acceptance notes
Verification
Local runs at the final head
See the os-dev report comment on #36770 for the head SHA, test counts and gate verdicts.
Two-minute check:
pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/dataset-compare-bucket-alignment.test.ts -t "no counterpart": 4 passed.Read first:
dataset-executor.tstherunComparerow loop (the drop), thenalignedCompareBucketKey's outside-window return.🤖 Generated with Claude Code
https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu