@@ -117,7 +117,7 @@ public async Task<bool> RecalculateAcceptedCount(Game game, CancellationToken to
117
117
. GroupBy ( i => i . ChallengeId )
118
118
. Select ( g => new { ChallengeId = g . Key , Count = g . Count ( ) } ) ;
119
119
120
- await Context . GameChallenges . IgnoreAutoIncludes ( )
120
+ await Context . GameChallenges . AsNoTracking ( ) . IgnoreAutoIncludes ( )
121
121
. Where ( c => query . Any ( r => r . ChallengeId == c . Id ) )
122
122
. ExecuteUpdateAsync (
123
123
setter =>
@@ -126,8 +126,24 @@ await Context.GameChallenges.IgnoreAutoIncludes()
126
126
c => query . First ( r => r . ChallengeId == c . Id ) . Count ) ,
127
127
token ) ;
128
128
129
- await cacheHelper . FlushScoreboardCache ( game . Id , token ) ;
129
+ var attempts = Context . Submissions . AsNoTracking ( )
130
+ . IgnoreAutoIncludes ( )
131
+ . Where ( s => s . GameId == game . Id )
132
+ . GroupBy ( s => new { s . ChallengeId , s . ParticipationId } )
133
+ . Select ( g => new { g . Key . ChallengeId , g . Key . ParticipationId , Count = g . Count ( ) } ) ;
134
+
135
+ await Context . GameInstances . AsNoTracking ( ) . IgnoreAutoIncludes ( )
136
+ . Where ( i => attempts . Any ( a =>
137
+ a . ChallengeId == i . ChallengeId && a . ParticipationId == i . ParticipationId ) )
138
+ . ExecuteUpdateAsync (
139
+ setter => setter . SetProperty (
140
+ i => i . SubmissionCount ,
141
+ i => attempts . First ( a =>
142
+ a . ChallengeId == i . ChallengeId && a . ParticipationId == i . ParticipationId ) . Count ) ,
143
+ token ) ;
144
+
130
145
await trans . CommitAsync ( token ) ;
146
+ await cacheHelper . FlushScoreboardCache ( game . Id , token ) ;
131
147
}
132
148
catch
133
149
{
0 commit comments