fix(automations): Use workflow stats time range - #125141
Conversation
Consume authoritative response bounds for the chart domain while accepting the legacy array response during deployment. Refs ISWF-853 Co-authored-by: Claude <noreply@anthropic.com>
| timeframe?: WorkflowStatsResponse['meta']; | ||
| }; | ||
|
|
||
| function normalizeWorkflowStatsResponse( |
There was a problem hiding this comment.
this function is here temporarily while we move the endpoint to the new format. follow up to remove this normalization
| data: stats.values.map(({timestamp, value}) => ({ | ||
| name: timestamp, | ||
| value: value ?? 0, |
There was a problem hiding this comment.
Bug: The chart renders raw numeric timestamps on its x-axis for legacy data because isGroupedByDate is not set, causing the axis type to default to 'category' instead of 'time'.
Severity: MEDIUM
Suggested Fix
In AutomationStatsChart, when handling the legacy data path (where stats.timeframe is undefined), explicitly pass isGroupedByDate={true} to the BarChart component. This will ensure the x-axis is correctly configured as a 'time' axis, allowing it to format the numeric timestamps into human-readable dates.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: static/app/views/automations/components/automationStatsChart.tsx#L135-L137
Potential issue: In the legacy data path, when `stats.timeframe` is undefined, the
`AutomationStatsChart` component does not configure the x-axis for time-series data. The
underlying `BaseChart` defaults `isGroupedByDate` to `false`, which sets the x-axis type
to `'category'`. As the data points now use numeric timestamps instead of date strings,
the chart will render these large, unformatted numbers as category labels on the x-axis
instead of properly formatted dates. This issue is expected to occur during deployment
while both new and legacy API response formats are supported.
Did we get this right? 👍 / 👎 to inform future reviews.
I'd like to make some minor changes to this workflow stats endpoint, related to ISWF-853. The manifested problem is that the bar chart does not take time bounds in. This is because the endpoint that this component uses is a bit unusual in that it only does hourly stats and it does not follow the normal format for an endpoint like this. This change is the first step in making this endpoint return time bounds, which will fix the fundamental issue.
Refs ISWF-853