diff --git a/Wordle.Api/Wordle.Api/Services/GameService.cs b/Wordle.Api/Wordle.Api/Services/GameService.cs index ed59432a..f4e38a99 100644 --- a/Wordle.Api/Wordle.Api/Services/GameService.cs +++ b/Wordle.Api/Wordle.Api/Services/GameService.cs @@ -54,4 +54,25 @@ public async Task GetGameStats(Game game) return stats; } + + public IQueryable StatsForAllWords() + { + IQueryable result = Db.Games + .Include(g => g.Word) + .GroupBy(g => g.Word!.Text) + .Select(g => new AllWordStats() + { + Word = g.Key, + AverageGuesses = g.Average(x => x.Attempts) + }); + + return result; + } +} + +public class AllWordStats() +{ + public required string Word { get; set; } + + public double AverageGuesses { get; set; } } diff --git a/wordle-web/pages/index.vue b/wordle-web/pages/index.vue index bca138fb..f7271593 100644 --- a/wordle-web/pages/index.vue +++ b/wordle-web/pages/index.vue @@ -1,10 +1,6 @@