File tree Expand file tree Collapse file tree 3 files changed +25
-20
lines changed
Expand file tree Collapse file tree 3 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -138,17 +138,21 @@ public override async Task Handle(HandlerContext<Command> context)
138138 Roster [ ] toRemove = rosters . Where ( x => foundMatchIds . Contains ( x . BitsMatchId ) == false ) . ToArray ( ) ;
139139 if ( toRemove . Any ( ) )
140140 {
141- string joined = string . Join (
142- "," ,
143- toRemove . Select ( x => $ "Id={ x . Id } BitsMatchId={ x . BitsMatchId } ") ) ;
144- Logger . InfoFormat ( "Rosters to remove: {joined}" , joined ) ;
141+ List < Roster > actualRemoved = new ( ) ;
145142 foreach ( Roster roster in toRemove )
146143 {
147- CompositionRoot . DocumentSession . Delete ( roster ) ;
144+ if ( roster . MatchResultId is null && roster . Turn > 20 )
145+ {
146+ CompositionRoot . DocumentSession . Delete ( roster ) ;
147+ actualRemoved . Add ( roster ) ;
148+ }
148149 }
149150
150- string body =
151- $ "Rosters to remove: { joined } ";
151+ string joined = string . Join (
152+ "," ,
153+ actualRemoved . Select ( x => $ "Id={ x . Id } BitsMatchId={ x . BitsMatchId } ") ) ;
154+ Logger . InfoFormat ( "Rosters to remove: {joined}" , joined ) ;
155+ string body = $ "Rosters to remove: { joined } ";
152156 SendEmail email = SendEmail . ToAdmin (
153157 $ "Removed rosters for { CompositionRoot . CurrentTenant . TeamFullName } ",
154158 body ) ;
Original file line number Diff line number Diff line change @@ -60,7 +60,8 @@ public override async Task Handle(HandlerContext<Command> context)
6060 }
6161 else
6262 {
63- MatchResult ? matchResult = CompositionRoot . EventStoreSession . Load < MatchResult > ( roster . MatchResultId ) ;
63+ MatchResult ? matchResult =
64+ CompositionRoot . EventStoreSession . Load < MatchResult > ( roster . MatchResultId ) ;
6465 ParseResult ? parseResult = parser . Parse ( bitsMatchResult , websiteConfig . ClubId ) ;
6566 update . Players = parseResult ! . GetPlayerIds ( ) ;
6667 Dictionary < string , ResultForPlayerIndex . Result > resultsForPlayer =
@@ -82,7 +83,7 @@ public override async Task Handle(HandlerContext<Command> context)
8283 }
8384 }
8485
85- roster . UpdateWith ( context . CorrelationId , update ) ;
86+ _ = roster . UpdateWith ( context . CorrelationId , update ) ;
8687 }
8788
8889 public record Command (
Original file line number Diff line number Diff line change @@ -79,6 +79,17 @@ public static SelectListItem[] CreatePlayerSelectList(
7979 return playerList . ToArray ( ) ;
8080 }
8181
82+ public static TResult LoadEx < TResult > ( this Raven . Client . IDocumentSession session , string key )
83+ {
84+ return session . Load < TResult > ( key ) ?? throw new Exception ( $ "No entity with key '{ key } ' found") ;
85+ }
86+
87+ public static User FindUserByEmail ( this Raven . Client . IDocumentSession sess , string email )
88+ {
89+ return sess . Query < User , User_ByEmail > ( )
90+ . FirstOrDefault ( u => u . Email == email ) ;
91+ }
92+
8293 private static SelectListItem [ ] GetRosterSelectList (
8394 Raven . Client . IDocumentSession session ,
8495 int season ,
@@ -113,15 +124,4 @@ private static SelectListItem[] GetRosterSelectList(
113124 . ToArray ( ) ;
114125 return rosterSelectList ;
115126 }
116-
117- public static TResult LoadEx < TResult > ( this Raven . Client . IDocumentSession session , string key )
118- {
119- return session . Load < TResult > ( key ) ?? throw new Exception ( $ "No entity with key '{ key } ' found") ;
120- }
121-
122- public static User FindUserByEmail ( this Raven . Client . IDocumentSession sess , string email )
123- {
124- return sess . Query < User , User_ByEmail > ( )
125- . FirstOrDefault ( u => u . Email == email ) ;
126- }
127127}
You can’t perform that action at this time.
0 commit comments