Add "flat" front history view (percentages add up to 100%)
This commit is contained in:
parent
bc32943824
commit
c727a71161
@ -523,8 +523,9 @@ namespace PluralKit.Bot
|
||||
title.Append($"`{targetSystem.Hid}`");
|
||||
|
||||
var ignoreNoFronters = ctx.MatchFlag("fo", "fronters-only");
|
||||
var showFlat = ctx.MatchFlag("flat");
|
||||
var frontpercent = await _db.Execute(c => _repo.GetFrontBreakdown(c, targetSystem.Id, target.Id, rangeStart.Value.ToInstant(), now));
|
||||
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, targetSystem, target, targetSystem.Zone, ctx.LookupContextFor(targetSystem), title.ToString(), ignoreNoFronters));
|
||||
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, targetSystem, target, targetSystem.Zone, ctx.LookupContextFor(targetSystem), title.ToString(), ignoreNoFronters, showFlat));
|
||||
}
|
||||
|
||||
private async Task<PKSystem> GetGroupSystem(Context ctx, PKGroup target, IPKConnection conn)
|
||||
|
@ -135,8 +135,9 @@ namespace PluralKit.Bot
|
||||
title.Append($"`{system.Hid}`");
|
||||
|
||||
var ignoreNoFronters = ctx.MatchFlag("fo", "fronters-only");
|
||||
var showFlat = ctx.MatchFlag("flat");
|
||||
var frontpercent = await _db.Execute(c => _repo.GetFrontBreakdown(c, system.Id, null, rangeStart.Value.ToInstant(), now));
|
||||
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, system, null, system.Zone, ctx.LookupContextFor(system), title.ToString(), ignoreNoFronters));
|
||||
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, system, null, system.Zone, ctx.LookupContextFor(system), title.ToString(), ignoreNoFronters, showFlat));
|
||||
}
|
||||
}
|
||||
}
|
@ -334,7 +334,7 @@ namespace PluralKit.Bot {
|
||||
return eb.Build();
|
||||
}
|
||||
|
||||
public Task<Embed> CreateFrontPercentEmbed(FrontBreakdown breakdown, PKSystem system, PKGroup group, DateTimeZone tz, LookupContext ctx, string embedTitle, bool ignoreNoFronters)
|
||||
public Task<Embed> CreateFrontPercentEmbed(FrontBreakdown breakdown, PKSystem system, PKGroup group, DateTimeZone tz, LookupContext ctx, string embedTitle, bool ignoreNoFronters, bool showFlat)
|
||||
{
|
||||
string color = system.Color;
|
||||
if (group != null)
|
||||
@ -352,16 +352,31 @@ namespace PluralKit.Bot {
|
||||
embedColor = DiscordUtils.Gray;
|
||||
}
|
||||
|
||||
var period = breakdown.RangeEnd - breakdown.RangeStart;
|
||||
var actualPeriod = period;
|
||||
|
||||
if (ignoreNoFronters)
|
||||
period = period - breakdown.NoFronterDuration;
|
||||
|
||||
var eb = new EmbedBuilder()
|
||||
.Title(embedTitle)
|
||||
.Color(embedColor)
|
||||
.Footer(new($"Since {breakdown.RangeStart.FormatZoned(tz)} ({actualPeriod.FormatDuration()} ago)"));
|
||||
.Color(embedColor);
|
||||
|
||||
string footer = $"Since {breakdown.RangeStart.FormatZoned(tz)} ({(breakdown.RangeEnd - breakdown.RangeStart).FormatDuration()} ago)";
|
||||
|
||||
Duration period;
|
||||
|
||||
if (showFlat)
|
||||
{
|
||||
period = Duration.FromTicks(breakdown.MemberSwitchDurations.Values.ToList().Sum(i => i.TotalTicks));
|
||||
footer += ". Showing flat list (percentages add up to 100%)";
|
||||
if (!ignoreNoFronters) period += breakdown.NoFronterDuration;
|
||||
else footer += ", ignoring switch-outs";
|
||||
}
|
||||
else if (ignoreNoFronters)
|
||||
{
|
||||
period = breakdown.RangeEnd - breakdown.RangeStart - breakdown.NoFronterDuration;
|
||||
footer += ". Ignoring switch-outs";
|
||||
}
|
||||
else
|
||||
period = breakdown.RangeEnd - breakdown.RangeStart;
|
||||
|
||||
eb.Footer(new(footer));
|
||||
|
||||
var maxEntriesToDisplay = 24; // max 25 fields allowed in embed - reserve 1 for "others"
|
||||
|
||||
// We convert to a list of pairs so we can add the no-fronter value
|
||||
|
@ -73,4 +73,5 @@ These flags only work with the full member list (`pk;system list full`).
|
||||
|Command|Flag|Aliases|Description|
|
||||
|---|---|---|---|
|
||||
|pk;system frontpercent|-fronters-only|-fo|Shows the system's frontpercent without the "no fronter" entry|
|
||||
|pk;system frontpercent|-flat||Shows "flat" frontpercent - percentages add up to 100%|
|
||||
|pk;group \<group> frontpercent|-fronters-only|-fo|Shows a group's frontpercent without the "no fronter" entry|
|
||||
|
@ -462,6 +462,15 @@ To look at the per-member breakdown of the front over a given time period, use t
|
||||
pk;system qazws frontpercent 100d12h
|
||||
|
||||
Note that in cases of switches with multiple members, each involved member will have the full length of the switch counted towards it. This means that the percentages may add up to over 100%.
|
||||
<br> It is possible to disable this with the `-flat` flag; percentages will then add up to 100%.
|
||||
|
||||
::: tip
|
||||
If you use the `switch-out` function, the time when no-one was fronting will show up in front history as "no fronter". To disable this, use the `-fronters-only`, or `-fo` flag:
|
||||
|
||||
```
|
||||
pk;system frontpercent -fronters-only
|
||||
```
|
||||
:::
|
||||
|
||||
## Member groups
|
||||
PluralKit allows you to categorize system members in different **groups**.
|
||||
|
Loading…
Reference in New Issue
Block a user