Skip to content

Commit 21e4b1d

Browse files
committed
Date and job status formatting
1 parent 256f124 commit 21e4b1d

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

site/frontend/src/pages/status_new/collector.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import {ref, Ref} from "vue";
3+
import {formatISODate} from "../../utils/formatting";
34
import {CollectorConfig, BenchmarkJobStatus} from "./data";
45
56
const props = defineProps<{
@@ -26,6 +27,19 @@ const ACTIVE_FILTERS: Ref<Record<BenchmarkJobStatus, boolean>> = ref({
2627
function filterJobByStatus(status: string) {
2728
ACTIVE_FILTERS.value[status] = !ACTIVE_FILTERS.value[status];
2829
}
30+
31+
function formatJobStatus(status: BenchmarkJobStatus): string {
32+
switch (status) {
33+
case "InProgress":
34+
return "In progress";
35+
case "Success":
36+
case "Failed":
37+
case "Queued":
38+
return status;
39+
default:
40+
return "Unknown";
41+
}
42+
}
2943
</script>
3044

3145
<template>
@@ -62,14 +76,14 @@ function filterJobByStatus(status: string) {
6276
<span class="collector-meta-name">
6377
<strong>Last Heartbeat:</strong>
6478
</span>
65-
<span>{{ collector.lastHeartbeatAt }}</span>
79+
<span>{{ formatISODate(collector.lastHeartbeatAt) }}</span>
6680
</div>
6781

6882
<div class="collector-meta">
6983
<span class="collector-meta-name">
7084
<strong>Date Added:</strong>
7185
</span>
72-
<span>{{ collector.dateAdded }}</span>
86+
<span>{{ formatISODate(collector.dateAdded) }}</span>
7387
</div>
7488
</div>
7589

@@ -83,7 +97,7 @@ function filterJobByStatus(status: string) {
8397
class="table-collector-status-filter-btn"
8498
@click="filterJobByStatus(filter)"
8599
>
86-
{{ filter }}
100+
{{ formatJobStatus(filter) }}
87101
<input
88102
type="checkbox"
89103
value="filter"
@@ -115,10 +129,10 @@ function filterJobByStatus(status: string) {
115129
{{ job.requestTag }}
116130
</td>
117131
<td class="table-cell-padding">
118-
{{ job.status }}
132+
{{ formatJobStatus(job.status) }}
119133
</td>
120134
<td class="table-cell-padding">
121-
{{ job.startedAt }}
135+
{{ formatISODate(job.startedAt) }}
122136
</td>
123137
<td class="table-cell-padding">{{ job.backend }}</td>
124138
<td class="table-cell-padding">{{ job.profile }}</td>

site/frontend/src/pages/status_new/page.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {h, ref, Ref} from "vue";
44
import {getJson} from "../../utils/requests";
55
import {STATUS_DATA_NEW_URL} from "../../urls";
66
import {withLoading} from "../../utils/loading";
7-
import {formatSecondsAsDuration} from "../../utils/formatting";
7+
import {formatSecondsAsDuration, formatISODate} from "../../utils/formatting";
88
import {useExpandedStore} from "../../utils/expansion";
99
import {
1010
BenchmarkRequest,
@@ -158,7 +158,7 @@ loadStatusData(loading);
158158
req.status === "Completed" && req.hasPendingJobs ? "*" : ""
159159
}}
160160
</td>
161-
<td v-html="req.completedAt"></td>
161+
<td v-html="formatISODate(req.completedAt)"></td>
162162
<td v-html="getDuration(req)"></td>
163163

164164
<td v-if="hasErrors(req.errors)">

site/frontend/src/utils/formatting.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {parseISO, format} from "date-fns";
2+
13
// `time` has to be in seconds
24
export function formatSecondsAsDuration(time: number): string {
35
let seconds = time % 60;
@@ -17,3 +19,11 @@ export function formatSecondsAsDuration(time: number): string {
1719
}
1820
return s;
1921
}
22+
23+
// Takes a date like `2025-09-10T08:22:47.161348Z` -> `"2025-09-10 08:22:47"`
24+
export function formatISODate(dateString?: string): string {
25+
if (dateString) {
26+
return format(parseISO(dateString), "yyyy-MM-dd HH:mm:ss");
27+
}
28+
return "";
29+
}

0 commit comments

Comments
 (0)