Skip to content

Commit

Permalink
fix: Sparkline in pipeline 3000 to be 7 bars
Browse files Browse the repository at this point in the history
  • Loading branch information
tiina303 committed Mar 1, 2024
1 parent 0808d36 commit ac7febe
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions frontend/src/scenes/pipeline/AppMetricSparkLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@ export function AppMetricSparkLine({ pipelineNode }: { pipelineNode: PipelineNod
const logic = pipelineNodeMetricsLogic({ pluginConfigId: pipelineNode.id })
const { appMetricsResponse } = useValues(logic)

// The metrics response has last 7 days time wise, we're showing the
// sparkline graph by day, so ignore the potential 8th day
const successes = appMetricsResponse ? appMetricsResponse.metrics.successes.slice(-7) : []
const failures = appMetricsResponse ? appMetricsResponse.metrics.failures.slice(-7) : []
const dates = appMetricsResponse ? appMetricsResponse.metrics.dates.slice(-7) : []

const displayData: SparklineTimeSeries[] = [
{
color: 'success',
name: 'Events sent',
values: appMetricsResponse ? appMetricsResponse.metrics.successes : [],
values: successes,
},
]
if (appMetricsResponse?.metrics.failures.some((failure) => failure > 0)) {
displayData.push({
color: 'danger',
name: 'Events dropped',
values: appMetricsResponse ? appMetricsResponse.metrics.failures : [],
values: failures,
})
}

return (
<Sparkline
loading={appMetricsResponse === null}
labels={appMetricsResponse ? appMetricsResponse.metrics.dates : []}
data={displayData}
className="max-w-24"
/>
<Sparkline loading={appMetricsResponse === null} labels={dates} data={displayData} className="max-w-24" />
)
}
}

0 comments on commit ac7febe

Please sign in to comment.