Skip to content

Commit ac23782

Browse files
committed
Show time since a job has started
1 parent 714fcaf commit ac23782

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<script setup lang="tsx">
22
import {h, ref, Ref} from "vue";
3-
import {parseISO, differenceInHours} from "date-fns";
4-
import {formatISODate} from "../../utils/formatting";
3+
import {parseISO, differenceInHours, differenceInSeconds} from "date-fns";
4+
import {
5+
formatISODate,
6+
formatSecondsAsDuration,
7+
parseDateIsoStringOrNull,
8+
} from "../../utils/formatting";
59
import {
610
CollectorConfig,
711
BenchmarkJobStatus,
@@ -101,6 +105,15 @@ function formatProfile(job: BenchmarkJob): string {
101105
return "";
102106
}
103107
}
108+
function timeSince(timestamp: string): string {
109+
const date = parseDateIsoStringOrNull(timestamp);
110+
if (date === null) {
111+
return "";
112+
}
113+
const now = new Date();
114+
const diffSeconds = differenceInSeconds(now, date);
115+
return formatSecondsAsDuration(diffSeconds);
116+
}
104117
</script>
105118

106119
<template>
@@ -187,7 +200,7 @@ function formatProfile(job: BenchmarkJob): string {
187200
<td>
188201
{{ formatJobStatus(job.status) }}
189202
</td>
190-
<td>
203+
<td :title="`Started ${timeSince(job.startedAt)} ago`">
191204
{{ formatISODate(job.startedAt) }}
192205
</td>
193206
<td>

0 commit comments

Comments
 (0)