Wire NowPlayingStats to live aggregates: add SQL track duration column, stats endpoint, and duration backfill

This commit is contained in:
daniel-c-harvey
2026-06-18 11:53:49 -04:00
parent 8ddecb4acc
commit 5f0422a263
26 changed files with 1089 additions and 9 deletions
@@ -0,0 +1,19 @@
namespace DeepDrftPublic.Client.Helpers;
/// <summary>
/// Formats a runtime expressed in seconds as a compact <c>hh:mm</c> string for the home hero stat row.
/// Hours are not zero-padded and may exceed two digits (mixes are few, so a large total simply renders
/// "123:45"); minutes are always two digits. Negative or non-finite inputs clamp to "0:00".
/// </summary>
public static class RuntimeFormat
{
public static string ToHoursMinutes(double totalSeconds)
{
if (double.IsNaN(totalSeconds) || double.IsInfinity(totalSeconds) || totalSeconds <= 0)
return "0:00";
var total = TimeSpan.FromSeconds(totalSeconds);
var hours = (int)total.TotalHours;
return $"{hours}:{total.Minutes:D2}";
}
}