Repository navigation
Description
There is no way to ask Orbit a question about a period of time. The analytics page reports on all issues that have ever existed in the workspace, and the only control on it is a toggle between counting issues and counting points.
"How did we do last quarter" is the most common question anyone asks an analytics page, and Orbit cannot answer it.
This is missing at every level, not just in the UI, so it has to be added at every level.
The engine has no concept of a date range
chartRequestSchema in packages/core/src/analytics/schemas.ts is:
export const chartRequestSchema = z.object({
scope: analyticsScopeSchema,
xAxis: chartDimensionSchema,
segment: chartDimensionSchema.optional(),
measure: measureSchema,
});No dates. scopeClause in distribution.ts filters on organisation, archived state and visible teams, and nothing else. scopeSeries computes its own bounds from min(created_at) to the last completion, so it always covers all of history.
What to build
In the engine, packages/core/src/analytics/:
- Add an optional range to
chartRequestSchemaand to the input types. Two ISO dates, inclusive start, exclusive end, both optional so an absent range keeps today's behaviour. - Decide and write down which date the range filters on. This is the part that matters and the part that is easy to get wrong. A distribution by assignee over "last month" could reasonably mean issues created last month, issues completed last month, or issues that were open at any point last month. They give very different numbers. Our suggestion is that the range filters on
completed_atfor anything measuring throughput and oncreated_atfor anything measuring intake, and that the UI says which one it is doing. Argue for something else on this thread if you disagree, but the answer has to be explicit and documented, not implied by the SQL. - Thread the range through
scopeClause,buildChart,workDistribution,stateGroupBreakdownandscopeSeries. scopeSeriesshould use the range as its bucket bounds when one is given, instead of deriving bounds from the data. Pick the bucket size from the range width: days for a range under about six weeks, weeks under about a year, months beyond that.
In the UI, apps/web/src/features/analytics/:
- A range control in the page header next to the existing
MeasureToggle. Presets carry almost all the value: last 7 days, last 30 days, this quarter, last quarter, this year, all time. A custom range picker is worth having but is not the first slice. - Put the range in the URL the way
measurealready is, so a range is linkable and survives a refresh. - Saved analytics views should store the range. See
savedAnalyticsViewCreateSchemainschemas.tsand thesaved_analytics_viewtable.
Watch out for
- The empty state currently says "No issues in range" in
breakdown-section.tsxeven though there is no range. Once there is one, that string is finally true, and it should say which range. - Every existing caller passes no range. Keep the parameter optional so nothing breaks, and let the page opt in.
- Indexes.
issue_team_created_idxandissue_org_active_idxexist and cover some of this. Check the plan for a range filtered distribution before assuming it is fine.
Tests
packages/core/tests/analytics/ has fixtures in test-fixtures.ts for inserting issues at specific timestamps. Add cases that assert an issue outside the range is excluded, and one that pins the created versus completed decision so a later refactor cannot quietly flip it.
This is one of the highest value changes on the analytics milestone. Comment before starting so we can agree the created versus completed question first.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNeeds design
Activity
imshashank commentedon Aug 8, 2026
Related to #179, which is the performance issue on the same page.
The bounding this issue adds to
scopeSeriesremoves a meaningful part of the cost measured there, so #179 explicitly defers date range work to this issue. Do not solve caching here, and do not solve bounding there.The chart builder in #182 and the scope picker in #178 both need to inherit whatever range control this issue introduces, so put the range in the URL and in the saved view payload rather than in component state.
imshashank commentedon Aug 15, 2026
Done, closing. This landed with the planning cockpit in #309, in a different shape than the issue proposed.
A reporting range now exists at every level this issue asked for:
analyticsRangeSchemainpackages/shared/src/validators/analytics.tscarriesauto,active_sprint,previous_sprint,last_30_days,last_90_days,all_time, and acustomrange with validatedfrom/to. It sits onanalyticsQuerySchemaalongsidelens,measure,compare,filterandfocus.packages/core/src/analytics/filter.tsresolves the range against a reporting timezone and derives the bucket granularity from the range width, capped atMAX_BUCKETS. Series no longer derive their own bounds frommin(created_at), which was the specific complaint in point 4.apps/web/src/features/analytics/date-range-picker.tsx, in the toolbar next to the measure control, with the presets above plus a custom from/to form.query-state.tsserialises the whole query, so a range is linkable and survives a refresh.savedDashboardConfigSchemainpackages/core/src/analytics/schemas.tsstores the fullanalyticsQuerySchema, range included.Two differences from the plan here, both deliberate and worth recording:
chartRequestSchema. That schema andPOST /api/analytics/chartstill exist unchanged, and the range lives on the new lens query model instead. That leavesbuildChartwithout a range, which matters for A chart builder over the dimensions the engine already supports #182.formulas()inpackages/core/src/analytics/sprints.ts, and surfaced on the sprint lens. So the answer is explicit and in the payload, which was the requirement.