Skip to content

Commit

Permalink
feat: Different sorting for long gamedays
Browse files Browse the repository at this point in the history
Gamedays with more than 10 games are first sorted by completed (i.e., completed games are pushed to the end) and then by date
  • Loading branch information
Tobi2K committed Jan 13, 2024
1 parent 6ba88e0 commit 2d0e493
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/game/game.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,18 @@ export class GameService {
}

async getGamedayFormatted(day: Game, user: User, group: Group) {
const games = await this.gameRepository.find({
let games = await this.gameRepository.find({
where: { gameday: day.gameday, season: day.season },
order: { date: 'ASC' },
});

if (games.length > 10) {
games = await this.gameRepository.find({
where: { gameday: day.gameday, season: day.season },
order: { completed: 'ASC', date: 'ASC' },
});
}

const guesses = await this.connection.getRepository(Guess).find({
where: {
user: user,
Expand Down

0 comments on commit 2d0e493

Please sign in to comment.