diff --git a/MyApp.ServiceInterface/LeaderboardServices.cs b/MyApp.ServiceInterface/LeaderboardServices.cs index 3fbbb70..b1d20b0 100644 --- a/MyApp.ServiceInterface/LeaderboardServices.cs +++ b/MyApp.ServiceInterface/LeaderboardServices.cs @@ -41,9 +41,13 @@ public async Task Any(CalculateLeaderBoard request) private CalculateLeaderboardResponse CalculateLeaderboardResponse(List statTotals, List statsByUser, List answers) { var statQuestions = statTotals.Where(x => !x.Id.Contains('-')).ToList(); + + // There might not be answers to some questions which we want to exclude from the win rate + statQuestions = statQuestions.Where(x => answers.Any(y => y.PostId == x.PostId)).ToList(); var overallWinRates = statsByUser.GroupBy(x => x.Id).Select(y => { + // sum all the wins for this user var res = new LeaderBoardWinRate { Id = y.Key,