feat(views/stats): update duration numbers to be more human readable #26

merged
opened by brookjeynes.dev targeting master from push-mxzpoqmltpmn
Changed files
+8 -9
internal
server
views
+8 -9
internal/server/views/partials/horizonal-bar-chart.templ
···
<div class="flex flex-col gap-3 px-6">
for _, item := range params.Data {
{{
-
widthPercentage := 0.0
-
if item.MaxValue > 0 {
-
widthPercentage = (item.Value.Seconds() / item.MaxValue.Seconds()) * 100
-
}
+
widthPercentage := 0.0
+
if item.MaxValue > 0 {
+
widthPercentage = (item.Value.Seconds() / item.MaxValue.Seconds()) * 100
+
}
}}
<div class="flex items-center gap-2 text-sm">
<span title={ item.Label } class="w-28 truncate text-right">{ item.Label }</span>
<div class="flex-grow bg-gray-light rounded-md h-6">
-
<div
-
class="bg-primary h-6 rounded-md"
-
style={ fmt.Sprintf("width: %.2f%%", widthPercentage) }
-
></div>
+
<div class="bg-primary h-6 rounded-md" style={ fmt.Sprintf("width: %.2f%%", widthPercentage) }></div>
</div>
-
<span class="w-12 font-medium text-text-muted">{ item.Value }</span>
+
<span title={ item.Value } class="w-12 font-medium text-text-muted text-nowrap">
+
{ FormatDuration(item.Value) }
+
</span>
</div>
}
</div>