Skip to content

feat(analytics): raw-value drill sidecar for totals/subtotal rows (#3214) - #3215

Merged
os-zhuang merged 1 commit into
mainfrom
claude/analytics-totals-subtotal-drill-hbqn0u
Jul 18, 2026
Merged

feat(analytics): raw-value drill sidecar for totals/subtotal rows (#3214)#3215
os-zhuang merged 1 commit into
mainfrom
claude/analytics-totals-subtotal-drill-hbqn0u

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Summary

Closes#3214.

ADR-0021 D2 drill metadata snapshots each row's raw grouped values into a parallel drillRawRows array beforeresolveDimensionLabels overwrites row[dim] with the display label — so a report drill filters by the stored value (FK id, select option value). But that snapshot only covered result.rows.

The totals/subtotal rows added in #1753 also carry dimension values (a row subtotal is keyed by its row bucket) and go through the same label resolution (analytics-service.ts, the for (const total of result.totals ?? []) loop). No raw values were captured for them, so a subtotal row ended up in the pre-#1750 state — display label only, stored value lost. A drill from a subtotal (e.g. clicking a "Q2 · Backlog" cell) then couldn't exact-match a lookup/select dimension.

Changes

  • packages/services/service-analytics/src/analytics-service.ts — in the ADR-0021 D2 drill block (the pre-label-resolution pass), also snapshot totals rows into a new drillRawTotals sidecar:
    • Aligned to result.totals by index: drillRawTotals[i]result.totals[i], drillRawTotals[i][j]result.totals[i].rows[j].
    • Restricted to the drillable dimensions each grouping actually groups by, so the grand-total grouping ([]) contributes an empty map per row (which keeps the index alignment and drills the whole, unfiltered object).
    • Purely additive extra props on the result, same as feat(analytics): dimension labels + drill-through metadata for dataset reports #2080no spec-contract change.
  • packages/services/service-analytics/src/__tests__/query-dataset.test.ts — two new tests:
    • alignment/shape of drillRawTotals across a subtotal grouping + grand total;
    • the raw FK survives in the sidecar even after label resolution rewrites the subtotal row's dimension to the display name.
  • Changeset (minor for @objectstack/service-analytics).

Notes

objectui's ReportView.handleDatasetDrill consumes drillRawRows for data rows only and subtotal drill isn't wired up yet, so this gap is latent today — this closes it on the framework side so the raw values are available if/when subtotal drill ships.

Verification

  • vitest run for @objectstack/service-analytics — 166 passed (14 files), including the 2 new tests.
  • tsc --noEmit — no new type errors introduced (two unrelated pre-existing errors in analytics-service.test.ts / native-sql-granularity-decline.test.ts are untouched by this change).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vejtto9wLCMUjQ9NFrXqnK


Generated by Claude Code

)
The ADR-0021 D2 drill metadata snapshots each row's raw grouped values
into a parallel `drillRawRows` array before `resolveDimensionLabels`
overwrites `row[dim]` with the display label — but the snapshot only
covered `result.rows`. The totals/subtotal rows (#1753) carry dimension
values too and go through the same label resolution, so a lookup/select
subtotal ended up label-only with the stored value lost — a subtotal
drill had nothing to exact-match on.
Snapshot raw values for totals rows too, in the same pre-label pass:
`drillRawTotals` is aligned to `result.totals` by index and restricted
to each grouping's drillable dims (the grand-total grouping `[]` yields
empty maps). Purely additive result props, same as #2080 — no
spec-contract change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vejtto9wLCMUjQ9NFrXqnK
@vercel

vercelBot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJul 18, 2026 1:58pm

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

6 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/automation/webhooks.mdx(via packages/services)
  • content/docs/kernel/runtime-services/audit-service.mdx(via packages/services)
  • content/docs/kernel/runtime-services/index.mdx(via packages/services)
  • content/docs/kernel/runtime-services/settings-service.mdx(via packages/services)
  • content/docs/plugins/packages.mdx(via packages/services)
  • content/docs/protocol/kernel/i18n-standard.mdx(via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang marked this pull request as ready for review July 18, 2026 14:10
@os-zhuang
os-zhuang merged commit a9459e6 into mainJul 18, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/analytics-totals-subtotal-drill-hbqn0u branch July 18, 2026 14:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analytics: totals/subtotal rows have no raw-value drill sidecar (drillRawRows covers result.rows only)

2 participants

@os-zhuang@claude