Pin a chart to the last few runs of a flow
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
compareQueryOptions,
|
||||
NO_CURVE,
|
||||
runMetricsQueryOptions,
|
||||
shortId,
|
||||
shortenRunLabel,
|
||||
} from "./queries"
|
||||
|
||||
/** The metrics one run recorded, in the order they are worth offering. */
|
||||
@@ -46,11 +46,7 @@ export function RunMetricChart({
|
||||
compareQueryOptions(ids, metric, refreshMs),
|
||||
)
|
||||
const lines = (data?.lines ?? []).slice(0, MAX_SERIES)
|
||||
const labels = lines.map((line) =>
|
||||
// The endpoint labels a line with the whole run id, which is too long to
|
||||
// read in a legend beside four others.
|
||||
line.label.replace(/^\S+/, (id) => shortId(id)),
|
||||
)
|
||||
const labels = lines.map((line) => shortenRunLabel(line.label))
|
||||
const plots: HistoryPoint[][] = lines.map((line) =>
|
||||
(line.points ?? []).map(([step, value]) => ({ ts: step, value })),
|
||||
)
|
||||
|
||||
@@ -61,6 +61,14 @@ export const runsInfiniteQueryOptions = (filters: RunFilters) => ({
|
||||
},
|
||||
})
|
||||
|
||||
/** One page of runs, for a caller that pages nothing — a pinned chart. */
|
||||
export const runsListQueryOptions = (
|
||||
filters: RunFilters & { limit?: number },
|
||||
) => ({
|
||||
queryKey: [...runKeys.all, "pinned", filters] as const,
|
||||
queryFn: () => RunsService.readRuns(filters),
|
||||
})
|
||||
|
||||
export const runOverviewQueryOptions = () => ({
|
||||
queryKey: runKeys.overview,
|
||||
queryFn: () => RunsService.readOverview(),
|
||||
@@ -138,6 +146,15 @@ export const NO_CURVE =
|
||||
/** A run id, short enough for a table cell. The tail is the random half. */
|
||||
export const shortId = (id: string) => id.slice(-8)
|
||||
|
||||
/**
|
||||
* A series label from the comparison endpoint, cut down to fit a legend.
|
||||
*
|
||||
* It leads with the whole run id, which is 22 characters of mostly timestamp
|
||||
* beside four others.
|
||||
*/
|
||||
export const shortenRunLabel = (label: string) =>
|
||||
label.replace(/^\S+/, (id) => shortId(id))
|
||||
|
||||
/** A commit, at the length everyone reads one at. */
|
||||
export const shortCommit = (commit: string) => commit.slice(0, 7)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user