From c313f21aeffbfab8a22a30ae32d9f418bda26ac6 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 11 Nov 2021 02:01:34 +0000 Subject: [PATCH] I spelt Milliseconds wrong... --- server/src/external/mongo/db.ts | 4 +-- server/src/external/redis/redis.ts | 4 +-- server/src/lib/jobs/ugs-snapshot.ts | 4 +-- server/src/lib/logger/discord-transport.ts | 2 +- .../framework/common/score-utils.ts | 2 +- .../framework/score-import-main.ts | 36 +++++++++---------- .../common/batch-manual/parser.test.ts | 4 +-- .../common/batch-manual/parser.ts | 2 +- server/src/utils/misc.test.ts | 6 ++-- server/src/utils/misc.ts | 4 +-- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/server/src/external/mongo/db.ts b/server/src/external/mongo/db.ts index c7a2e9994..5c054b428 100644 --- a/server/src/external/mongo/db.ts +++ b/server/src/external/mongo/db.ts @@ -40,7 +40,7 @@ import { UserMilestoneDocument, UserSettings, } from "tachi-common"; -import { GetMilisecondsSince } from "utils/misc"; +import { GetMillisecondsSince } from "utils/misc"; const logger = CreateLogCtx(__filename); @@ -63,7 +63,7 @@ export const monkDB = monk(`${Environment.mongoUrl}/${dbName}`, { /* istanbul ignore next */ monkDB .then(() => { - logger.info(`Database connection successful: took ${GetMilisecondsSince(dbtime)}ms`, { + logger.info(`Database connection successful: took ${GetMillisecondsSince(dbtime)}ms`, { bootInfo: true, }); }) diff --git a/server/src/external/redis/redis.ts b/server/src/external/redis/redis.ts index a74326d76..03566aed8 100644 --- a/server/src/external/redis/redis.ts +++ b/server/src/external/redis/redis.ts @@ -2,7 +2,7 @@ import { ONE_MINUTE } from "lib/constants/time"; import CreateLogCtx from "lib/logger/logger"; import { Environment } from "lib/setup/config"; import redis from "redis"; -import { GetMilisecondsSince } from "utils/misc"; +import { GetMillisecondsSince } from "utils/misc"; const logger = CreateLogCtx(__filename); @@ -27,7 +27,7 @@ function EmitCritical() { const ref = setTimeout(EmitCritical, ONE_MINUTE * 2); RedisClient.on("connect", () => { - logger.info(`Connected to Redis. Took ${GetMilisecondsSince(startConnect)}ms`, { + logger.info(`Connected to Redis. Took ${GetMillisecondsSince(startConnect)}ms`, { bootInfo: true, }); diff --git a/server/src/lib/jobs/ugs-snapshot.ts b/server/src/lib/jobs/ugs-snapshot.ts index 580f53afb..3c9ee51bb 100644 --- a/server/src/lib/jobs/ugs-snapshot.ts +++ b/server/src/lib/jobs/ugs-snapshot.ts @@ -2,7 +2,7 @@ import { UserGameStats, UserGameStatsSnapshot } from "tachi-common"; import db from "external/mongo/db"; import CreateLogCtx from "lib/logger/logger"; import { GetUsersRanking } from "utils/user"; -import { GetMilisecondsSince } from "utils/misc"; +import { GetMillisecondsSince } from "utils/misc"; const logger = CreateLogCtx(__filename); @@ -70,7 +70,7 @@ export async function UGSSnapshot() { logger.info( `Successfully snapshotted all data as of ${new Date( currentTime - ).toString()}. Took ${GetMilisecondsSince(timeStart)} ms.` + ).toString()}. Took ${GetMillisecondsSince(timeStart)} ms.` ); } catch (err) { // if we panic, we need to revert whatever we did. diff --git a/server/src/lib/logger/discord-transport.ts b/server/src/lib/logger/discord-transport.ts index 945d43f67..c8972983f 100644 --- a/server/src/lib/logger/discord-transport.ts +++ b/server/src/lib/logger/discord-transport.ts @@ -200,7 +200,7 @@ export default class DiscordTransport extends Transport { // It's possible that messages here could all get stuck in an // awful loop, so we have a tuning off parameter. // The scaleRetryDebouncer will get squared every call, - // so the initial request takes 2 * (generally 1milisecond), + // so the initial request takes 2 * (generally 1milliseconds), // then following requests will take even longer... // It's possible this might blow up in our face. // We'll have to see. - zkldi 2021/09/17 diff --git a/server/src/lib/score-import/framework/common/score-utils.ts b/server/src/lib/score-import/framework/common/score-utils.ts index ee9a86f80..4b22b807f 100644 --- a/server/src/lib/score-import/framework/common/score-utils.ts +++ b/server/src/lib/score-import/framework/common/score-utils.ts @@ -146,7 +146,7 @@ export function CalculateESDForGame( /** * Parses and validates a date from a string. - * @returns Miliseconds from the unix epoch, or null if the initial argument was null or undefined. + * @returns Millisecondss from the unix epoch, or null if the initial argument was null or undefined. */ export function ParseDateFromString(str: string | undefined | null): number | null { if (!str) { diff --git a/server/src/lib/score-import/framework/score-import-main.ts b/server/src/lib/score-import/framework/score-import-main.ts index 071b3819c..0637a224b 100644 --- a/server/src/lib/score-import/framework/score-import-main.ts +++ b/server/src/lib/score-import/framework/score-import-main.ts @@ -12,7 +12,7 @@ import { KtLogger } from "lib/logger/logger"; import { ImportAllIterableData } from "./score-importing/score-importing"; import { CreateImportLoggerAndID } from "./common/import-logger"; import { CreateSessions } from "./sessions/sessions"; -import { GetMilisecondsSince } from "utils/misc"; +import { GetMillisecondsSince } from "utils/misc"; import { ProcessPBs } from "./pb/process-pbs"; import { UpdateUsersGamePlaytypeStats } from "./user-game-stats/update-ugs"; import db from "external/mongo/db"; @@ -48,7 +48,7 @@ export default async function ScoreImportMain( // // Under normal circumstances, there is no scenario where a user would have two ongoing // imports at the same time - even if they were using single-score imports on a 5 second - // chart, as each score import takes only around ~10-15miliseconds. + // chart, as each score import takes only around ~10-15millisecondss. throw new ScoreImportFatalError(409, "This user already has an ongoing import."); } @@ -73,9 +73,9 @@ export default async function ScoreImportMain( const parseTimeStart = process.hrtime.bigint(); const { iterable, context, game, classHandler } = await InputParser(logger); - const parseTime = GetMilisecondsSince(parseTimeStart); + const parseTime = GetMillisecondsSince(parseTimeStart); - logger.debug(`Parsing took ${parseTime} miliseconds.`); + logger.debug(`Parsing took ${parseTime} millisecondss.`); // We have to cast here due to typescript generic confusions. This is guaranteed` to be correct. const ConverterFunction = Converters[importType] as unknown as ConverterFunction; @@ -93,10 +93,10 @@ export default async function ScoreImportMain( logger ); - const importTime = GetMilisecondsSince(importTimeStart); + const importTime = GetMillisecondsSince(importTimeStart); const importTimeRel = importTime / importInfo.length; - logger.debug(`Importing took ${importTime} miliseconds. (${importTimeRel}ms/doc)`); + logger.debug(`Importing took ${importTime} millisecondss. (${importTimeRel}ms/doc)`); // Steps 3-8 are handled inside here. // This was moved inside here so the score de-orphaning process @@ -203,11 +203,11 @@ export async function HandlePostImportSteps( const importParseTimeStart = process.hrtime.bigint(); const { scorePlaytypeMap, errors, scoreIDs, chartIDs } = ParseImportInfo(importInfo); - const importParseTime = GetMilisecondsSince(importParseTimeStart); + const importParseTime = GetMillisecondsSince(importParseTimeStart); const importParseTimeRel = importParseTime / importInfo.length; logger.debug( - `Import Parsing took ${importParseTime} miliseconds. (${importParseTimeRel}ms/doc)` + `Import Parsing took ${importParseTime} millisecondss. (${importParseTimeRel}ms/doc)` ); // --- 4. Sessions --- @@ -216,10 +216,10 @@ export async function HandlePostImportSteps( const sessionTimeStart = process.hrtime.bigint(); const sessionInfo = await CreateSessions(user.id, importType, game, scorePlaytypeMap, logger); - const sessionTime = GetMilisecondsSince(sessionTimeStart); + const sessionTime = GetMillisecondsSince(sessionTimeStart); const sessionTimeRel = sessionTime / sessionInfo.length; - logger.debug(`Session Processing took ${sessionTime} miliseconds (${sessionTimeRel}ms/doc).`); + logger.debug(`Session Processing took ${sessionTime} millisecondss (${sessionTimeRel}ms/doc).`); // --- 5. PersonalBests --- // We want to keep an updated reference of a users best score on a given chart. @@ -228,10 +228,10 @@ export async function HandlePostImportSteps( const pbTimeStart = process.hrtime.bigint(); await ProcessPBs(user.id, chartIDs, logger); - const pbTime = GetMilisecondsSince(pbTimeStart); + const pbTime = GetMillisecondsSince(pbTimeStart); const pbTimeRel = pbTime / chartIDs.size; - logger.debug(`PB Processing took ${pbTime} miliseconds (${pbTimeRel}ms/doc)`); + logger.debug(`PB Processing took ${pbTime} millisecondss (${pbTimeRel}ms/doc)`); const playtypes = Object.keys(scorePlaytypeMap) as Playtypes[Game][]; @@ -240,27 +240,27 @@ export async function HandlePostImportSteps( const ugsTimeStart = process.hrtime.bigint(); const classDeltas = await UpdateUsersGameStats(game, playtypes, user.id, classHandler, logger); - const ugsTime = GetMilisecondsSince(ugsTimeStart); + const ugsTime = GetMillisecondsSince(ugsTimeStart); - logger.debug(`UGS Processing took ${ugsTime} miliseconds.`); + logger.debug(`UGS Processing took ${ugsTime} millisecondss.`); // --- 7. Goals --- // Evaluate and update the users goals. This returns information about goals that have changed. const goalTimeStart = process.hrtime.bigint(); const goalInfo = await GetAndUpdateUsersGoals(game, user.id, chartIDs, logger); - const goalTime = GetMilisecondsSince(goalTimeStart); + const goalTime = GetMillisecondsSince(goalTimeStart); - logger.debug(`Goal Processing took ${goalTime} miliseconds.`); + logger.debug(`Goal Processing took ${goalTime} millisecondss.`); // --- 8. Milestones --- // Evaluate and update the users milestones. This returns... const milestoneTimeStart = process.hrtime.bigint(); const milestoneInfo = await UpdateUsersMilestones(goalInfo, game, playtypes, user.id, logger); - const milestoneTime = GetMilisecondsSince(milestoneTimeStart); + const milestoneTime = GetMillisecondsSince(milestoneTimeStart); - logger.debug(`Milestone Processing took ${milestoneTime} miliseconds.`); + logger.debug(`Milestone Processing took ${milestoneTime} millisecondss.`); return { classDeltas, diff --git a/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts b/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts index ff08a0ab3..4b7d9f8c5 100644 --- a/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts +++ b/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts @@ -380,7 +380,7 @@ t.test("#ParserFn", (t) => { fn, new ScoreImportFatalError( 400, - "Invalid BATCH-MANUAL: scores[0].timeAchieved | Expected a number greater than 1 Trillion - did you pass unix seconds instead of miliseconds? | Received string [string]." + "Invalid BATCH-MANUAL: scores[0].timeAchieved | Expected a number greater than 1 Trillion - did you pass unix seconds instead of millisecondss? | Received string [string]." ) ); @@ -395,7 +395,7 @@ t.test("#ParserFn", (t) => { fn2, new ScoreImportFatalError( 400, - "Invalid BATCH-MANUAL: scores[0].timeAchieved | Expected a number greater than 1 Trillion - did you pass unix seconds instead of miliseconds? | Received 1620768609.637 [number]." + "Invalid BATCH-MANUAL: scores[0].timeAchieved | Expected a number greater than 1 Trillion - did you pass unix seconds instead of millisecondss? | Received 1620768609.637 [number]." ), "Should throw if timeAchieved is less than 10_000_000_000." ); diff --git a/server/src/lib/score-import/import-types/common/batch-manual/parser.ts b/server/src/lib/score-import/import-types/common/batch-manual/parser.ts index 1d4c7906d..c6000d704 100644 --- a/server/src/lib/score-import/import-types/common/batch-manual/parser.ts +++ b/server/src/lib/score-import/import-types/common/batch-manual/parser.ts @@ -138,7 +138,7 @@ const PR_BatchManualScore = (game: Game, playtype: Playtypes[Game]): PrudenceSch timeAchieved: optNull( (self) => (typeof self === "number" && self > 1_000_000_000_000) || - "Expected a number greater than 1 Trillion - did you pass unix seconds instead of miliseconds?" + "Expected a number greater than 1 Trillion - did you pass unix seconds instead of millisecondss?" ), judgements: optNull((self) => { if (typeof self !== "object" || self === null) { diff --git a/server/src/utils/misc.test.ts b/server/src/utils/misc.test.ts index 5ac99b695..c6c01109b 100644 --- a/server/src/utils/misc.test.ts +++ b/server/src/utils/misc.test.ts @@ -1,8 +1,8 @@ import t from "tap"; -import { GetMilisecondsSince, IsValidURL } from "./misc"; +import { GetMillisecondsSince, IsValidURL } from "./misc"; -t.test("#GetMilisecondsSince", (t) => { - const time = GetMilisecondsSince(10n); +t.test("#GetMillisecondssSince", (t) => { + const time = GetMillisecondsSince(10n); t.ok(typeof time === "number" && time > 0, "Should return a number greater than 0."); t.end(); diff --git a/server/src/utils/misc.ts b/server/src/utils/misc.ts index 3fa7385f4..3046d52b9 100644 --- a/server/src/utils/misc.ts +++ b/server/src/utils/misc.ts @@ -18,10 +18,10 @@ export function EscapeStringRegexp(string: string) { } /** - * Takes a process.hrtime.bigint(), and returns the miliseconds elapsed since it. + * Takes a process.hrtime.bigint(), and returns the millisecondss elapsed since it. * This function will not work if more than 100(ish) days have passed since the first reference. */ -export function GetMilisecondsSince(ref: bigint) { +export function GetMillisecondsSince(ref: bigint) { return Number(process.hrtime.bigint() - ref) / 1e6; }