duration can be passed as null from the parser so handle that in frontpercent

This commit is contained in:
dusk 2025-11-26 17:03:01 +00:00
parent 271ea9c27b
commit 25bf0d85d4
No known key found for this signature in database

View file

@ -104,7 +104,7 @@ public class SystemFront
); );
} }
public async Task FrontPercent(Context ctx, PKSystem? system = null, string durationStr = "30d", bool ignoreNoFronters = false, bool showFlat = false, PKGroup? group = null) public async Task FrontPercent(Context ctx, PKSystem? system, string? durationStr, bool ignoreNoFronters = false, bool showFlat = false, PKGroup? group = null)
{ {
if (system == null && group == null) throw Errors.NoSystemError(ctx.DefaultPrefix); if (system == null && group == null) throw Errors.NoSystemError(ctx.DefaultPrefix);
if (system == null) system = await GetGroupSystem(ctx, group); if (system == null) system = await GetGroupSystem(ctx, group);
@ -114,6 +114,9 @@ public class SystemFront
var totalSwitches = await ctx.Repository.GetSwitchCount(system.Id); var totalSwitches = await ctx.Repository.GetSwitchCount(system.Id);
if (totalSwitches == 0) throw Errors.NoRegisteredSwitches; if (totalSwitches == 0) throw Errors.NoRegisteredSwitches;
if (durationStr == null)
durationStr = "30d";
// Picked the UNIX epoch as a random date // Picked the UNIX epoch as a random date
// even though we don't store switch timestamps in UNIX time // even though we don't store switch timestamps in UNIX time
// I assume most people won't have switches logged previously to that (?) // I assume most people won't have switches logged previously to that (?)