Skip to content

Commit

Permalink
fix: prevent same contest appear multi times
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Aug 4, 2022
1 parent d0b68ce commit 26d568c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import pangu from "pangu";
import { randomUUID } from "crypto";
import { Command } from "commander";
import { bin, version } from "../package.json";
import _ from "lodash";
import { readFileSync } from "fs";
import AwaitLock from "await-lock";

Expand Down Expand Up @@ -115,7 +114,7 @@ async function checkCache()
if(contestsCache.lastUpdate < Date.now() - 1000 * 60 * 5)
{
const c = await new Lscontests({ days: -1 }).getContests();
contestsCache.contests = _.uniqBy(contestsCache.contests.concat(c.running.concat(c.upcoming)), JSON.stringify);
contestsCache.contests = c.running.concat(...c.upcoming);
contestsCache.contests = contestsCache.contests.filter(
c => c.endTime.getTime() - c.startTime.getTime() < 1000 * 60 * 60 * 24 * 2
); // ignore too long contests
Expand Down

0 comments on commit 26d568c

Please sign in to comment.