Skip to content

Commit

Permalink
updateLatestSeason: forceful kv set op
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Oct 16, 2023
1 parent 9896822 commit 10bf85a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/leaderboard/denokv/denokv_leaderboard_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ export class DenoKvLeaderboardClient implements LeaderboardClient {
/**
* updateLatestSeason updates the latest season in Deno KV.
*/
private async updateLatestSeason(
season: api.Season,
prevSeasonResult: Deno.KvEntryMaybe<api.Season> | null,
): Promise<void> {
private async updateLatestSeason(season: api.Season): Promise<void> {
// Update the season.
const updateSeasonOp = this.kv.atomic();
if (prevSeasonResult) {
updateSeasonOp.check(prevSeasonResult);
}

// Update the season.
const updateSeasonResult = await updateSeasonOp.set(
Expand Down Expand Up @@ -183,7 +177,7 @@ export class DenoKvLeaderboardClient implements LeaderboardClient {
// Update the season if it is the latest season.
startOfWeekDate.getTime() === seasonStartDate.getTime();
if (isLatestSeason) {
await this.updateLatestSeason(season, seasonResult);
await this.updateLatestSeason(season);
}

// Return a sync response.
Expand Down

0 comments on commit 10bf85a

Please sign in to comment.