Skip to content

Commit 5250a41

Browse files
committed
fix
1 parent d8e1e95 commit 5250a41

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Snittlistan.Web/Commands/GetRostersFromBitsCommandHandler.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,21 @@ public override async Task Handle(HandlerContext<Command> context)
135135
}
136136

137137
// remove extraneous rosters
138-
Roster[] toRemove = rosters.Where(x => foundMatchIds.Contains(x.BitsMatchId) == false).ToArray();
138+
Roster[] toRemove = rosters
139+
.Where(x => foundMatchIds.Contains(x.BitsMatchId) == false
140+
&& x.MatchResultId is null
141+
&& x.Turn <= 20)
142+
.ToArray();
139143
if (toRemove.Any())
140144
{
141-
List<Roster> actualRemoved = new();
142145
foreach (Roster roster in toRemove)
143146
{
144-
// only regular season games, playoff is handled differently
145-
if (roster.MatchResultId is null && roster.Turn <= 20)
146-
{
147-
CompositionRoot.DocumentSession.Delete(roster);
148-
actualRemoved.Add(roster);
149-
}
147+
CompositionRoot.DocumentSession.Delete(roster);
150148
}
151149

152150
string joined = string.Join(
153151
",",
154-
actualRemoved.Select(x => $"Id={x.Id} BitsMatchId={x.BitsMatchId}"));
152+
toRemove.Select(x => $"Id={x.Id} BitsMatchId={x.BitsMatchId}"));
155153
Logger.InfoFormat("Rosters to remove: {joined}", joined);
156154
string body = $"Rosters to remove: {joined}";
157155
SendEmail email = SendEmail.ToAdmin(

0 commit comments

Comments
 (0)