fix timespan when removing no-fronters

This commit is contained in:
spiral 2021-06-21 10:52:06 -04:00
parent 0dfea56d83
commit bc32943824
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -352,9 +352,11 @@ namespace PluralKit.Bot {
embedColor = DiscordUtils.Gray;
}
var actualPeriod = breakdown.RangeEnd - breakdown.RangeStart;
// this is kinda messy?
var hasFrontersPeriod = Duration.FromTicks(breakdown.MemberSwitchDurations.Values.ToList().Sum(i => i.TotalTicks));
var period = breakdown.RangeEnd - breakdown.RangeStart;
var actualPeriod = period;
if (ignoreNoFronters)
period = period - breakdown.NoFronterDuration;
var eb = new EmbedBuilder()
.Title(embedTitle)
@ -371,7 +373,7 @@ namespace PluralKit.Bot {
var membersOrdered = pairs.OrderByDescending(pair => pair.Value).Take(maxEntriesToDisplay).ToList();
foreach (var pair in membersOrdered)
{
var frac = pair.Value / (ignoreNoFronters ? hasFrontersPeriod : actualPeriod);
var frac = pair.Value / period;
eb.Field(new(pair.Key?.NameFor(ctx) ?? "*(no fronter)*", $"{frac*100:F0}% ({pair.Value.FormatDuration()})"));
}