fix(ui): Show correct avg response time for N/A value (#1407)

* fix(ui): Show correct avg response time not applicable value

* refactor(ui): Convert to milliseconds after loop

---------

Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
PythonGermany
2025-11-29 01:56:02 +01:00
committed by GitHub
parent ee01adb603
commit 0c3231713f

View File

@@ -35,7 +35,7 @@
<CardTitle class="text-sm font-medium text-muted-foreground">Avg Response Time</CardTitle> <CardTitle class="text-sm font-medium text-muted-foreground">Avg Response Time</CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div class="text-2xl font-bold">{{ pageAverageResponseTime }}ms</div> <div class="text-2xl font-bold">{{ pageAverageResponseTime }}</div>
</CardContent> </CardContent>
</Card> </Card>
@@ -262,7 +262,7 @@ const pageAverageResponseTime = computed(() => {
} }
} }
if (count === 0) return 'N/A' if (count === 0) return 'N/A'
return Math.round(total / count / 1000000) return `${Math.round(total / count / 1000000)}ms`
}) })
const pageResponseTimeRange = computed(() => { const pageResponseTimeRange = computed(() => {
@@ -275,17 +275,17 @@ const pageResponseTimeRange = computed(() => {
let hasData = false let hasData = false
for (const result of endpointStatus.value.results) { for (const result of endpointStatus.value.results) {
if (result.duration) { const duration = result.duration
const durationMs = result.duration / 1000000 if (duration) {
min = Math.min(min, durationMs) min = Math.min(min, duration)
max = Math.max(max, durationMs) max = Math.max(max, duration)
hasData = true hasData = true
} }
} }
if (!hasData) return 'N/A' if (!hasData) return 'N/A'
const minMs = Math.round(min) const minMs = Math.round(min / 1000000)
const maxMs = Math.round(max) const maxMs = Math.round(max / 1000000)
// If min and max are the same, show single value // If min and max are the same, show single value
if (minMs === maxMs) { if (minMs === maxMs) {
return `${minMs}ms` return `${minMs}ms`