mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
parent
05f7ead62e
commit
b6ba24d171
2 changed files with 25 additions and 5 deletions
|
|
@ -314,11 +314,19 @@ namespace PluralKit {
|
|||
return outList;
|
||||
}
|
||||
|
||||
public async Task<IDictionary<PKMember, Duration>> GetPerMemberSwitchDuration(PKSystem system, Instant periodStart,
|
||||
public struct PerMemberSwitchDuration
|
||||
{
|
||||
public Dictionary<PKMember, Duration> MemberSwitchDurations;
|
||||
public Duration NoFronterDuration;
|
||||
}
|
||||
|
||||
public async Task<PerMemberSwitchDuration> GetPerMemberSwitchDuration(PKSystem system, Instant periodStart,
|
||||
Instant periodEnd)
|
||||
{
|
||||
var dict = new Dictionary<PKMember, Duration>();
|
||||
|
||||
var noFronterDuration = Duration.Zero;
|
||||
|
||||
// Sum up all switch durations for each member
|
||||
// switches with multiple members will result in the duration to add up to more than the actual period range
|
||||
foreach (var sw in await GetTruncatedSwitchList(system, periodStart, periodEnd))
|
||||
|
|
@ -328,9 +336,15 @@ namespace PluralKit {
|
|||
if (!dict.ContainsKey(member)) dict.Add(member, sw.TimespanWithinRange);
|
||||
else dict[member] += sw.TimespanWithinRange;
|
||||
}
|
||||
|
||||
if (sw.Members.Count == 0) noFronterDuration += sw.TimespanWithinRange;
|
||||
}
|
||||
|
||||
return dict;
|
||||
return new PerMemberSwitchDuration
|
||||
{
|
||||
MemberSwitchDurations = dict,
|
||||
NoFronterDuration = noFronterDuration
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue