diff options
author | AnInternetTroll <lucafulger@gmail.com> | 2022-03-11 17:37:01 +0000 |
---|---|---|
committer | AnInternetTroll <lucafulger@gmail.com> | 2022-03-11 17:37:01 +0000 |
commit | 2446aa01dabe8b2cefcced6294a1e32b8b9e8506 (patch) | |
tree | a1d3eac1591afdb90f15cdc7940e062f16801d4f | |
parent | e887cfa29919134a5d3a3d2dd06d0e39c8c58f69 (diff) | |
download | speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar.gz speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar.bz2 speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar.lz speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar.xz speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.tar.zst speedrunbot-slash-2446aa01dabe8b2cefcced6294a1e32b8b9e8506.zip |
Add better total examined runs and if rate limited wait for 30s instead of 90s
-rwxr-xr-x | src/srcom/examined.ts | 25 | ||||
-rwxr-xr-x | src/srcom/utils.ts | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/srcom/examined.ts b/src/srcom/examined.ts index 7f71fc1..6491af0 100755 --- a/src/srcom/examined.ts +++ b/src/srcom/examined.ts @@ -1,6 +1,12 @@ #!/usr/bin/env -S deno run --allow-net=www.speedrun.com --no-check import { Format } from "./fmt.ts"; -import { getAll, getGames, getUser, SRC_API } from "./utils.ts"; +import { + getAll, + getGames, + getUser, + SRC_API, + unofficialGetUserStats, +} from "./utils.ts"; import type { Opts } from "./utils.ts"; import type { SpeedrunCom } from "./types.d.ts"; interface ExaminedObject { @@ -52,15 +58,28 @@ export async function examined( let individualLevelRuns = 0; let verifiedRuns = 0; let rejectedRuns = 0; + let total = runs.length; runs.forEach((run) => { if (run.level) individualLevelRuns++; else fullGameRuns++; if (run.status.status === "verified") verifiedRuns++; else rejectedRuns++; }); + if (total === 10_000) { + try { + let totalExaminedRuns = 0; + const stats = await unofficialGetUserStats(user.id); + for (const modStat of stats.modStats) { + totalExaminedRuns += modStat.totalRuns; + } + if (totalExaminedRuns > total) total = totalExaminedRuns; + } catch (err) { + console.error(err); + } + } if (outputType === "object") { return { - total: runs.length, + total, fullGame: fullGameRuns, individualLevel: individualLevelRuns, verified: verifiedRuns, @@ -75,7 +94,7 @@ export async function examined( output.push(`Verified: ${verifiedRuns}`); output.push(`Rejected: ${rejectedRuns}`); output.push(""); - output.push(`Total: ${fullGameRuns + individualLevelRuns}`); + output.push(`Total: ${total}`); return output.join("\n"); } diff --git a/src/srcom/utils.ts b/src/srcom/utils.ts index 19839cf..0380095 100755 --- a/src/srcom/utils.ts +++ b/src/srcom/utils.ts @@ -87,7 +87,7 @@ export async function getAll<T>(url: URL | string): Promise<T[]> { console.warn("We are being throttled " + res.status); attempts++; if (attempts > 5) break; - await delay(90000); + await delay(30_000); } continue; } else attempts = 0; |