From d079b500366a85670d413996cc170c41e6163a86 Mon Sep 17 00:00:00 2001 From: barbeque-squared Date: Sun, 30 Jul 2023 11:08:58 +0200 Subject: [PATCH] on the highscores/top5 screen, only show the highest score per player. also adds a TODO because the filter is useless now? (not that it did anything to begin with...) --- src/base/UDataBase.pas | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/base/UDataBase.pas b/src/base/UDataBase.pas index 6cc5e85ce..3a2cf9109 100644 --- a/src/base/UDataBase.pas +++ b/src/base/UDataBase.pas @@ -514,12 +514,15 @@ procedure TDataBaseSystem.ReadScore(Song: TSong); TableData := nil; try // Search Song in DB + // TODO: isn't the whole filter completely unnecessary with the GROUP BY? + // if yes, why not just do a much simpler query for each difficulty? can also add LIMIT that way? TableData := ScoreDB.GetUniTable( 'SELECT [Difficulty], [Player], [Score], [Date] FROM [' + cUS_Scores + '] ' + 'WHERE [SongID] = (' + 'SELECT [ID] FROM [' + cUS_Songs + '] ' + 'WHERE [Artist] = ? AND [Title] = ? ' + 'LIMIT 1) ' + + 'GROUP BY [Difficulty], [Player] HAVING MAX([Score]) ' + 'ORDER BY [Score] DESC;', //no LIMIT! see filter below! [Song.Artist, Song.Title]);