[backend/razor] Render display durations >1000ms properly on queue dashboard
This commit is contained in:
parent
2e562b04d8
commit
503b8c5985
3 changed files with 33 additions and 17 deletions
|
@ -33,4 +33,26 @@ public static class NumberExtensions
|
|||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
public static string ToDurationDisplayString(this long input)
|
||||
{
|
||||
return input switch
|
||||
{
|
||||
< 1000 => $"{input} ms",
|
||||
< 1000 * 60 => $"{Math.Round(input / 1000d / 60d, 2)} s",
|
||||
< 1000 * 60 * 60 => $"{Math.Round(input / 60000d / 60d, 2)} m",
|
||||
_ => $"{Math.Round(input / 60000d / 60d / 60d, 2)} h"
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToDurationDisplayString(this int input)
|
||||
{
|
||||
return input switch
|
||||
{
|
||||
< 1000 => $"{input} ms",
|
||||
< 1000 * 60 => $"{Math.Round(input / 1000d / 60d, 2)} s",
|
||||
< 1000 * 60 * 60 => $"{Math.Round(input / 60000d / 60d, 2)} m",
|
||||
_ => $"{Math.Round(input / 60000d / 60d / 60d, 2)} h"
|
||||
};
|
||||
}
|
||||
}
|
|
@ -127,9 +127,9 @@ else
|
|||
var id = job.Id.ToStringLower();
|
||||
var additional = job.Status switch
|
||||
{
|
||||
Job.JobStatus.Queued => $"for {job.QueueDuration} ms",
|
||||
Job.JobStatus.Queued => $"for {job.QueueDuration.ToDurationDisplayString()}",
|
||||
Job.JobStatus.Running => $"for {job.Duration.ToDurationDisplayString()}",
|
||||
Job.JobStatus.Delayed => $"until {job.DelayedUntil?.ToDisplayStringTz() ?? "<unknown>"}",
|
||||
Job.JobStatus.Running => $"for {job.Duration} ms",
|
||||
Job.JobStatus.Completed => $"at {job.FinishedAt?.ToDisplayStringTz() ?? "<unknown>"}",
|
||||
Job.JobStatus.Failed => $"at {job.FinishedAt?.ToDisplayStringTz() ?? "<unknown>"}",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
|
|
|
@ -69,20 +69,14 @@
|
|||
<td>@(Model.Job.DelayedUntil?.ToDisplayStringTz() ?? "<unknown>")</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Job.Duration < 10000)
|
||||
{
|
||||
<tr>
|
||||
<td>Duration</td>
|
||||
<td>@Model.Job.Duration ms</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Job.QueueDuration < 10000)
|
||||
{
|
||||
<tr>
|
||||
<td>Queue duration</td>
|
||||
<td>@Model.Job.QueueDuration ms</td>
|
||||
</tr>
|
||||
}
|
||||
<tr>
|
||||
<td>Duration</td>
|
||||
<td>@Model.Job.Duration.ToDurationDisplayString()</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Queue duration</td>
|
||||
<td>@Model.Job.QueueDuration.ToDurationDisplayString()</td>
|
||||
</tr>
|
||||
@if (Model.Job.RetryCount > 0)
|
||||
{
|
||||
<tr>
|
||||
|
@ -204,4 +198,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
<button onclick="copyToClipboard(document.getElementById('data').textContent);">Copy to clipboard</button>
|
||||
<button onclick="copyToClipboard(document.getElementById('data').textContent);">Copy to clipboard</button>
|
Loading…
Add table
Reference in a new issue