2019-04-19 18:48:37 +00:00
using System.Collections.Generic ;
using System.Linq ;
using System.Threading.Tasks ;
2019-07-18 15:13:42 +00:00
using App.Metrics.Logging ;
2019-04-19 18:48:37 +00:00
using Dapper ;
2019-06-13 14:53:04 +00:00
using NodaTime ;
2019-07-18 15:13:42 +00:00
using Serilog ;
2019-04-19 18:48:37 +00:00
namespace PluralKit {
public class SystemStore {
2019-07-11 19:25:23 +00:00
private DbConnectionFactory _conn ;
2019-07-18 15:13:42 +00:00
private ILogger _logger ;
2019-04-19 18:48:37 +00:00
2019-07-18 15:13:42 +00:00
public SystemStore ( DbConnectionFactory conn , ILogger logger )
{
2019-07-11 19:25:23 +00:00
this . _conn = conn ;
2019-07-18 15:13:42 +00:00
_logger = logger . ForContext < SystemStore > ( ) ;
2019-04-19 18:48:37 +00:00
}
public async Task < PKSystem > Create ( string systemName = null ) {
// TODO: handle HID collision case
2019-04-21 13:33:22 +00:00
var hid = Utils . GenerateHid ( ) ;
2019-07-18 15:13:42 +00:00
PKSystem system ;
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-18 15:13:42 +00:00
system = await conn . QuerySingleAsync < PKSystem > ( "insert into systems (hid, name) values (@Hid, @Name) returning *" , new { Hid = hid , Name = systemName } ) ;
_logger . Information ( "Created system {System}" , system . Id ) ;
return system ;
2019-04-19 18:48:37 +00:00
}
2019-04-21 13:33:22 +00:00
public async Task Link ( PKSystem system , ulong accountId ) {
2019-07-11 20:46:18 +00:00
// We have "on conflict do nothing" since linking an account when it's already linked to the same system is idempotent
// This is used in import/export, although the pk;link command checks for this case beforehand
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 20:46:18 +00:00
await conn . ExecuteAsync ( "insert into accounts (uid, system) values (@Id, @SystemId) on conflict do nothing" , new { Id = accountId , SystemId = system . Id } ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Linked system {System} to account {Account}" , system . Id , accountId ) ;
2019-04-21 13:33:22 +00:00
}
2019-05-21 21:40:26 +00:00
public async Task Unlink ( PKSystem system , ulong accountId ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "delete from accounts where uid = @Id and system = @SystemId" , new { Id = accountId , SystemId = system . Id } ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Unlinked system {System} from account {Account}" , system . Id , accountId ) ;
2019-05-21 21:40:26 +00:00
}
2019-04-21 13:33:22 +00:00
2019-04-19 18:48:37 +00:00
public async Task < PKSystem > GetByAccount ( ulong accountId ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleOrDefaultAsync < PKSystem > ( "select systems.* from systems, accounts where accounts.system = systems.id and accounts.uid = @Id" , new { Id = accountId } ) ;
2019-04-19 18:48:37 +00:00
}
public async Task < PKSystem > GetByHid ( string hid ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleOrDefaultAsync < PKSystem > ( "select * from systems where systems.hid = @Hid" , new { Hid = hid . ToLower ( ) } ) ;
2019-04-19 18:48:37 +00:00
}
public async Task < PKSystem > GetByToken ( string token ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleOrDefaultAsync < PKSystem > ( "select * from systems where token = @Token" , new { Token = token } ) ;
2019-04-19 18:48:37 +00:00
}
2019-05-11 22:44:02 +00:00
public async Task < PKSystem > GetById ( int id )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleOrDefaultAsync < PKSystem > ( "select * from systems where id = @Id" , new { Id = id } ) ;
2019-05-11 22:44:02 +00:00
}
2019-04-19 18:48:37 +00:00
public async Task Save ( PKSystem system ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "update systems set name = @Name, description = @Description, tag = @Tag, avatar_url = @AvatarUrl, token = @Token, ui_tz = @UiTz where id = @Id" , system ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Updated system {@System}" , system ) ;
2019-04-19 18:48:37 +00:00
}
public async Task Delete ( PKSystem system ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "delete from systems where id = @Id" , system ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Deleted system {System}" , system . Id ) ;
2019-04-26 15:14:20 +00:00
}
2019-04-21 13:33:22 +00:00
public async Task < IEnumerable < ulong > > GetLinkedAccountIds ( PKSystem system )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QueryAsync < ulong > ( "select uid from accounts where system = @Id" , new { Id = system . Id } ) ;
2019-04-21 13:33:22 +00:00
}
2019-07-16 21:34:22 +00:00
public async Task < ulong > Count ( )
{
using ( var conn = await _conn . Obtain ( ) )
return await conn . ExecuteScalarAsync < ulong > ( "select count(id) from systems" ) ;
}
2019-04-19 18:48:37 +00:00
}
public class MemberStore {
2019-07-11 19:25:23 +00:00
private DbConnectionFactory _conn ;
2019-07-18 15:13:42 +00:00
private ILogger _logger ;
2019-04-19 18:48:37 +00:00
2019-07-18 15:13:42 +00:00
public MemberStore ( DbConnectionFactory conn , ILogger logger )
{
2019-07-11 19:25:23 +00:00
this . _conn = conn ;
2019-07-18 15:13:42 +00:00
_logger = logger . ForContext < MemberStore > ( ) ;
2019-04-19 18:48:37 +00:00
}
public async Task < PKMember > Create ( PKSystem system , string name ) {
// TODO: handle collision
2019-04-21 13:33:22 +00:00
var hid = Utils . GenerateHid ( ) ;
2019-07-18 15:13:42 +00:00
PKMember member ;
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-18 15:13:42 +00:00
member = await conn . QuerySingleAsync < PKMember > ( "insert into members (hid, system, name) values (@Hid, @SystemId, @Name) returning *" , new {
2019-07-11 19:25:23 +00:00
Hid = hid ,
SystemID = system . Id ,
Name = name
} ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Created member {Member}" , member . Id ) ;
return member ;
2019-04-19 18:48:37 +00:00
}
public async Task < PKMember > GetByHid ( string hid ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleOrDefaultAsync < PKMember > ( "select * from members where hid = @Hid" , new { Hid = hid . ToLower ( ) } ) ;
2019-04-19 18:48:37 +00:00
}
2019-04-27 14:30:34 +00:00
public async Task < PKMember > GetByName ( PKSystem system , string name ) {
2019-04-29 17:43:09 +00:00
// QueryFirst, since members can (in rare cases) share names
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QueryFirstOrDefaultAsync < PKMember > ( "select * from members where lower(name) = lower(@Name) and system = @SystemID" , new { Name = name , SystemID = system . Id } ) ;
2019-04-19 18:48:37 +00:00
}
public async Task < ICollection < PKMember > > GetUnproxyableMembers ( PKSystem system ) {
return ( await GetBySystem ( system ) )
. Where ( ( m ) = > {
var proxiedName = $"{m.Name} {system.Tag}" ;
return proxiedName . Length > 32 | | proxiedName . Length < 2 ;
} ) . ToList ( ) ;
}
public async Task < IEnumerable < PKMember > > GetBySystem ( PKSystem system ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QueryAsync < PKMember > ( "select * from members where system = @SystemID" , new { SystemID = system . Id } ) ;
2019-04-19 18:48:37 +00:00
}
public async Task Save ( PKMember member ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "update members set name = @Name, description = @Description, color = @Color, avatar_url = @AvatarUrl, birthday = @Birthday, pronouns = @Pronouns, prefix = @Prefix, suffix = @Suffix where id = @Id" , member ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Updated member {@Member}" , member ) ;
2019-04-19 18:48:37 +00:00
}
public async Task Delete ( PKMember member ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "delete from members where id = @Id" , member ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Deleted member {@Member}" , member ) ;
2019-04-19 18:48:37 +00:00
}
2019-05-11 22:44:02 +00:00
public async Task < int > MessageCount ( PKMember member )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QuerySingleAsync < int > ( "select count(*) from messages where member = @Id" , member ) ;
2019-05-11 22:44:02 +00:00
}
2019-07-15 15:36:10 +00:00
public async Task < int > MemberCount ( PKSystem system )
{
using ( var conn = await _conn . Obtain ( ) )
return await conn . ExecuteScalarAsync < int > ( "select count(*) from members where system = @Id" , system ) ;
}
2019-07-16 21:34:22 +00:00
public async Task < ulong > Count ( )
{
using ( var conn = await _conn . Obtain ( ) )
return await conn . ExecuteScalarAsync < ulong > ( "select count(id) from members" ) ;
}
2019-04-19 18:48:37 +00:00
}
public class MessageStore {
2019-06-21 11:49:58 +00:00
public struct PKMessage
{
2019-04-19 18:48:37 +00:00
public ulong Mid ;
2019-06-21 11:49:58 +00:00
public ulong Channel ;
public ulong Sender ;
}
public class StoredMessage
{
public PKMessage Message ;
2019-04-19 18:48:37 +00:00
public PKMember Member ;
public PKSystem System ;
}
2019-07-11 19:25:23 +00:00
private DbConnectionFactory _conn ;
2019-07-18 15:13:42 +00:00
private ILogger _logger ;
2019-04-19 18:48:37 +00:00
2019-07-18 15:13:42 +00:00
public MessageStore ( DbConnectionFactory conn , ILogger logger )
{
2019-07-11 19:25:23 +00:00
this . _conn = conn ;
2019-07-18 15:13:42 +00:00
_logger = logger . ForContext < MessageStore > ( ) ;
2019-04-19 18:48:37 +00:00
}
public async Task Store ( ulong senderId , ulong messageId , ulong channelId , PKMember member ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "insert into messages(mid, channel, member, sender) values(@MessageId, @ChannelId, @MemberId, @SenderId)" , new {
MessageId = messageId ,
ChannelId = channelId ,
MemberId = member . Id ,
SenderId = senderId
} ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Stored message {Message} in channel {Channel}" , messageId , channelId ) ;
2019-04-19 18:48:37 +00:00
}
2019-06-21 11:49:58 +00:00
public async Task < StoredMessage > Get ( ulong id )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return ( await conn . QueryAsync < PKMessage , PKMember , PKSystem , StoredMessage > ( "select messages.*, members.*, systems.* from messages, members, systems where mid = @Id and messages.member = members.id and systems.id = members.system" , ( msg , member , system ) = > new StoredMessage
{
Message = msg ,
System = system ,
Member = member
} , new { Id = id } ) ) . FirstOrDefault ( ) ;
2019-04-19 18:48:37 +00:00
}
public async Task Delete ( ulong id ) {
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "delete from messages where mid = @Id" , new { Id = id } ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Deleted message {Message}" , id ) ;
2019-04-19 18:48:37 +00:00
}
2019-07-16 21:34:22 +00:00
public async Task < ulong > Count ( )
{
using ( var conn = await _conn . Obtain ( ) )
return await conn . ExecuteScalarAsync < ulong > ( "select count(mid) from messages" ) ;
}
2019-04-19 18:48:37 +00:00
}
2019-06-13 14:53:04 +00:00
public class SwitchStore
{
2019-07-11 19:25:23 +00:00
private DbConnectionFactory _conn ;
2019-07-18 15:13:42 +00:00
private ILogger _logger ;
2019-06-13 14:53:04 +00:00
2019-07-18 15:13:42 +00:00
public SwitchStore ( DbConnectionFactory conn , ILogger logger )
2019-06-13 14:53:04 +00:00
{
2019-07-11 19:25:23 +00:00
_conn = conn ;
2019-07-18 15:13:42 +00:00
_logger = logger . ForContext < SwitchStore > ( ) ;
2019-06-13 14:53:04 +00:00
}
2019-07-18 15:13:42 +00:00
public async Task RegisterSwitch ( PKSystem system , ICollection < PKMember > members )
2019-06-13 14:53:04 +00:00
{
// Use a transaction here since we're doing multiple executed commands in one
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
using ( var tx = conn . BeginTransaction ( ) )
2019-06-13 14:53:04 +00:00
{
// First, we insert the switch itself
2019-07-11 19:25:23 +00:00
var sw = await conn . QuerySingleAsync < PKSwitch > ( "insert into switches(system) values (@System) returning *" ,
2019-06-13 14:53:04 +00:00
new { System = system . Id } ) ;
// Then we insert each member in the switch in the switch_members table
// TODO: can we parallelize this or send it in bulk somehow?
foreach ( var member in members )
{
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync (
2019-06-13 14:53:04 +00:00
"insert into switch_members(switch, member) values(@Switch, @Member)" ,
new { Switch = sw . Id , Member = member . Id } ) ;
}
// Finally we commit the tx, since the using block will otherwise rollback it
tx . Commit ( ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Registered switch {Switch} in system {System} with members {@Members}" , sw . Id , system . Id , members . Select ( m = > m . Id ) ) ;
2019-06-13 14:53:04 +00:00
}
}
2019-06-30 21:41:01 +00:00
public async Task < IEnumerable < PKSwitch > > GetSwitches ( PKSystem system , int count = 9999999 )
2019-06-13 14:53:04 +00:00
{
// TODO: refactor the PKSwitch data structure to somehow include a hydrated member list
// (maybe when we get caching in?)
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QueryAsync < PKSwitch > ( "select * from switches where system = @System order by timestamp desc limit @Count" , new { System = system . Id , Count = count } ) ;
2019-06-13 14:53:04 +00:00
}
2019-06-30 21:41:01 +00:00
public async Task < IEnumerable < int > > GetSwitchMemberIds ( PKSwitch sw )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-14 19:48:10 +00:00
return await conn . QueryAsync < int > ( "select member from switch_members where switch = @Switch order by switch_members.id" ,
2019-07-11 19:25:23 +00:00
new { Switch = sw . Id } ) ;
2019-06-30 21:41:01 +00:00
}
2019-06-13 14:53:04 +00:00
public async Task < IEnumerable < PKMember > > GetSwitchMembers ( PKSwitch sw )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
return await conn . QueryAsync < PKMember > (
2019-07-14 19:48:10 +00:00
"select * from switch_members, members where switch_members.member = members.id and switch_members.switch = @Switch order by switch_members.id" ,
2019-07-11 19:25:23 +00:00
new { Switch = sw . Id } ) ;
2019-06-13 14:53:04 +00:00
}
public async Task < PKSwitch > GetLatestSwitch ( PKSystem system ) = > ( await GetSwitches ( system , 1 ) ) . FirstOrDefault ( ) ;
public async Task MoveSwitch ( PKSwitch sw , Instant time )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "update switches set timestamp = @Time where id = @Id" ,
new { Time = time , Id = sw . Id } ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Moved switch {Switch} to {Time}" , sw . Id , time ) ;
2019-06-13 14:53:04 +00:00
}
2019-06-13 15:05:50 +00:00
public async Task DeleteSwitch ( PKSwitch sw )
{
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
await conn . ExecuteAsync ( "delete from switches where id = @Id" , new { Id = sw . Id } ) ;
2019-07-18 15:13:42 +00:00
_logger . Information ( "Deleted switch {Switch}" ) ;
2019-06-13 15:05:50 +00:00
}
2019-06-30 21:41:01 +00:00
2019-07-16 21:34:22 +00:00
public async Task < ulong > Count ( )
{
using ( var conn = await _conn . Obtain ( ) )
return await conn . ExecuteScalarAsync < ulong > ( "select count(id) from switches" ) ;
}
2019-06-30 21:41:01 +00:00
public struct SwitchListEntry
{
public ICollection < PKMember > Members ;
2019-07-16 19:18:46 +00:00
public Instant TimespanStart ;
public Instant TimespanEnd ;
2019-06-30 21:41:01 +00:00
}
public async Task < IEnumerable < SwitchListEntry > > GetTruncatedSwitchList ( PKSystem system , Instant periodStart , Instant periodEnd )
{
// TODO: only fetch the necessary switches here
// todo: this is in general not very efficient LOL
// returns switches in chronological (newest first) order
var switches = await GetSwitches ( system ) ;
// we skip all switches that happened later than the range end, and taking all the ones that happened after the range start
// *BUT ALSO INCLUDING* the last switch *before* the range (that partially overlaps the range period)
var switchesInRange = switches . SkipWhile ( sw = > sw . Timestamp > = periodEnd ) . TakeWhileIncluding ( sw = > sw . Timestamp > periodStart ) . ToList ( ) ;
// query DB for all members involved in any of the switches above and collect into a dictionary for future use
// this makes sure the return list has the same instances of PKMember throughout, which is important for the dictionary
// key used in GetPerMemberSwitchDuration below
2019-07-11 19:25:23 +00:00
Dictionary < int , PKMember > memberObjects ;
2019-07-14 03:23:27 +00:00
using ( var conn = await _conn . Obtain ( ) )
2019-07-11 19:25:23 +00:00
{
memberObjects = ( await conn . QueryAsync < PKMember > (
"select distinct members.* from members, switch_members where switch_members.switch = any(@Switches) and switch_members.member = members.id" , // lol postgres specific `= any()` syntax
new { Switches = switchesInRange . Select ( sw = > sw . Id ) . ToList ( ) } ) )
. ToDictionary ( m = > m . Id ) ;
}
2019-06-30 21:41:01 +00:00
// we create the entry objects
var outList = new List < SwitchListEntry > ( ) ;
// loop through every switch that *occurred* in-range and add it to the list
// end time is the switch *after*'s timestamp - we cheat and start it out at the range end so the first switch in-range "ends" there instead of the one after's start point
var endTime = periodEnd ;
foreach ( var switchInRange in switchesInRange )
{
// find the start time of the switch, but clamp it to the range (only applicable to the Last Switch Before Range we include in the TakeWhileIncluding call above)
var switchStartClamped = switchInRange . Timestamp ;
if ( switchStartClamped < periodStart ) switchStartClamped = periodStart ;
outList . Add ( new SwitchListEntry
{
Members = ( await GetSwitchMemberIds ( switchInRange ) ) . Select ( id = > memberObjects [ id ] ) . ToList ( ) ,
2019-07-16 19:18:46 +00:00
TimespanStart = switchStartClamped ,
TimespanEnd = endTime
2019-06-30 21:41:01 +00:00
} ) ;
// next switch's end is this switch's start
endTime = switchInRange . Timestamp ;
}
return outList ;
}
2019-07-15 19:51:41 +00:00
public struct PerMemberSwitchDuration
{
public Dictionary < PKMember , Duration > MemberSwitchDurations ;
public Duration NoFronterDuration ;
2019-07-16 19:18:46 +00:00
public Instant RangeStart ;
public Instant RangeEnd ;
2019-07-15 19:51:41 +00:00
}
public async Task < PerMemberSwitchDuration > GetPerMemberSwitchDuration ( PKSystem system , Instant periodStart ,
2019-06-30 21:41:01 +00:00
Instant periodEnd )
{
var dict = new Dictionary < PKMember , Duration > ( ) ;
2019-07-15 19:51:41 +00:00
var noFronterDuration = Duration . Zero ;
2019-06-30 21:41:01 +00:00
// 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
2019-07-16 19:18:46 +00:00
var actualStart = periodEnd ; // will be "pulled" down
var actualEnd = periodStart ; // will be "pulled" up
2019-06-30 21:41:01 +00:00
foreach ( var sw in await GetTruncatedSwitchList ( system , periodStart , periodEnd ) )
{
2019-07-16 19:18:46 +00:00
var span = sw . TimespanEnd - sw . TimespanStart ;
2019-06-30 21:41:01 +00:00
foreach ( var member in sw . Members )
{
2019-07-16 19:18:46 +00:00
if ( ! dict . ContainsKey ( member ) ) dict . Add ( member , span ) ;
else dict [ member ] + = span ;
2019-06-30 21:41:01 +00:00
}
2019-07-15 19:51:41 +00:00
2019-07-16 19:18:46 +00:00
if ( sw . Members . Count = = 0 ) noFronterDuration + = span ;
if ( sw . TimespanStart < actualStart ) actualStart = sw . TimespanStart ;
2019-07-17 11:37:43 +00:00
if ( sw . TimespanEnd > actualEnd ) actualEnd = sw . TimespanEnd ;
2019-06-30 21:41:01 +00:00
}
2019-07-15 19:51:41 +00:00
return new PerMemberSwitchDuration
{
MemberSwitchDurations = dict ,
2019-07-16 19:18:46 +00:00
NoFronterDuration = noFronterDuration ,
RangeStart = actualStart ,
RangeEnd = actualEnd
2019-07-15 19:51:41 +00:00
} ;
2019-06-30 21:41:01 +00:00
}
2019-06-13 14:53:04 +00:00
}
2019-04-19 18:48:37 +00:00
}