Skip to content

Commit

Permalink
updated highscore query
Browse files Browse the repository at this point in the history
  • Loading branch information
bennobuilder committed Jan 22, 2022
1 parent 4a3d4dd commit da88f84
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/src/ui/pages/dronieslab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const FlappyDronieScreen: React.FC = () => (
<FlappyDronieView />
<Spacer height={300} />
<MemoryDronieView />
<Spacer height={200} />
<Spacer height={350} />
</Container>
</PageLayout>
);
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/games/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export async function getRecentHighScores(
.from(GameLog, 'sub_gameLog')
.select('MAX("score")', 'max_score')
.addSelect('player_id')
.where('game_type = :gameType', { gameType })
.groupBy('player_id'),
'best_game',
'best_game.player_id = gameLog.player_id', // = ON best_game.player_id = gameLog.player_id
)
// https://stackoverflow.com/questions/65644410/typeorm-leftjoin-with-3-tables
.leftJoinAndSelect('gameLog.player', 'user', 'user.id = gameLog.player_id')
.where('best_game.max_score = gameLog.score')
.andWhere('gameLog.game_type = :gameType', { gameType })
.andWhere('gameLog.played_at > :date', { date: endIncludeDate })
.distinctOn(['gameLog.score']) // https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group
.orderBy('gameLog.score', 'DESC')
Expand Down

0 comments on commit da88f84

Please sign in to comment.