Skip to content

Commit 860f90b

Browse files
committed
fix(contest): exclude new leaderboard entries from top results
Filter out newly created (unsaved) leaderboard entries from the top leaderboard results to prevent temporary entries from affecting the display. Add a TODO to reconsider using `query` instead of `adapterOptions` or implement explicit caching for better handling.
1 parent 5baa56d commit 860f90b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/routes/contest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ export default class ContestRoute extends BaseRoute {
111111
}
112112
}
113113

114-
const topLeaderboardEntries = await this.store.findAll('leaderboard-entry', {
114+
// TODO[Vasyl]: This interacts with the usage in preferredLanguageLeaderboard where we create a temporary leaderboard entry
115+
// Figure out a way to use `query` instead of the adapterOptions strategy? Or maybe more explicit caching?
116+
let topLeaderboardEntries = (await this.store.findAll('leaderboard-entry', {
115117
adapterOptions: {
116118
leaderboard_id: contest.leaderboard.id,
117119
},
118120
include: 'user,leaderboard',
119-
});
121+
})) as unknown as LeaderboardEntryModel[];
122+
123+
topLeaderboardEntries = topLeaderboardEntries.reject((entry) => entry.isNew);
120124

121125
const languages = await this.store.findAll('language');
122126

0 commit comments

Comments
 (0)