diff --git a/internal/repository/stats.go b/internal/repository/stats.go index 484851d..3245b70 100644 --- a/internal/repository/stats.go +++ b/internal/repository/stats.go @@ -450,12 +450,15 @@ func (r *JobRepository) AddHistograms( ) (*model.JobsStatistics, error) { start := time.Now() + binSeconds := 900 + binMinutes := binSeconds / 60 castType := r.getCastType() var err error - value := fmt.Sprintf(`CAST(ROUND((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) / 3600) as %s) as value`, time.Now().Unix(), castType) + // Bin by job duration in sizes of binSeconds, add +1, gives Integers from 1-XX+1, re-multiply by binMinutes to get final bar x-values (logic: Jobs less than duration X in bin) + value := fmt.Sprintf(`CAST((ROUND(((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) / %d) + 1) * %d) as %s) as value`, time.Now().Unix(), binSeconds, binMinutes, castType) stat.HistDuration, err = r.jobsStatisticsHistogram(ctx, value, filter) if err != nil { - log.Warn("Error while loading job statistics histogram: running jobs") + log.Warn("Error while loading job statistics histogram: job duration") return nil, err } diff --git a/web/frontend/src/User.root.svelte b/web/frontend/src/User.root.svelte index 57f2f28..8f7ed57 100644 --- a/web/frontend/src/User.root.svelte +++ b/web/frontend/src/User.root.svelte @@ -213,9 +213,10 @@ {#key $stats.data.jobsStatistics[0].histDuration} t.map((v) => formatNumber(v)), + values: (_, t) => t.map((v) => { + if (!usesBins) console.log("X Scale Val", xlabel, v) + return formatNumber(v) + }), }, { stroke: "#000000", @@ -166,7 +170,10 @@ size: 5 / devicePixelRatio, stroke: "#000000", }, - values: (_, t) => t.map((v) => formatNumber(v)), + values: (_, t) => t.map((v) => { + if (!usesBins) console.log("Y Scale Val", ylabel, v) + return formatNumber(v) + }), }, ], series: [ diff --git a/web/frontend/src/generic/utils.js b/web/frontend/src/generic/utils.js index fa357eb..9d63617 100644 --- a/web/frontend/src/generic/utils.js +++ b/web/frontend/src/generic/utils.js @@ -405,7 +405,7 @@ function getMetricConfigDeep(metric, cluster, subCluster) { } } -export function convert2uplot(canvasData) { +export function convert2uplot(canvasData, minutesToHours = false) { // Prep: Uplot Data Structure let uplotData = [[],[]] // [X, Y1, Y2, ...] // Iterate if exists @@ -415,9 +415,15 @@ export function convert2uplot(canvasData) { uplotData[0].push(cd?.max ? cd.max : 0) uplotData[1].push(cd.count) } else { // Default - uplotData[0].push(cd.value) + if (minutesToHours) { + let hours = cd.value / 60 + console.log("x minutes to y hours", cd.value, hours) + uplotData[0].push(hours) + } else { + uplotData[0].push(cd.value) + } uplotData[1].push(cd.count) - } + } }) } return uplotData