diff --git a/server/src/db/schemas.ts b/server/src/db/schemas.ts index bfe032aee..5acd771dc 100644 --- a/server/src/db/schemas.ts +++ b/server/src/db/schemas.ts @@ -379,7 +379,7 @@ export const PRUDENCE_CHART_SCHEMAS: Record = { * does not depend on fields in the document (such as score docs) * being different depending on the score.game field. */ -export const STATIC_SCHEMAS: Partial, PrudenceSchema>> = { +export const STATIC_SCHEMAS = { users: PRUDENCE_PRIVATE_USER, "iidx-bpi-data": PRUDENCE_IIDX_BPI_DATA, counters: PRUDENCE_COUNTER, diff --git a/server/src/scripts/__KT_DATABASE_MIGRATION/charts-iidx.ts b/server/src/scripts/__KT_DATABASE_MIGRATION/charts-iidx.ts index d9f1d8e13..3dc35c883 100644 --- a/server/src/scripts/__KT_DATABASE_MIGRATION/charts-iidx.ts +++ b/server/src/scripts/__KT_DATABASE_MIGRATION/charts-iidx.ts @@ -12,7 +12,7 @@ function ConvertFn(c: any): ChartDocument<"iidx:SP" | "iidx:DP"> { playtype: c.playtype, levelNum: c.levelNum, isRemoved: false, - level: c.level, + level: c.level.toString(), length: c.length, bpmString: "", // sentinel flags: { diff --git a/server/src/scripts/validate-database.ts b/server/src/scripts/validate-database.ts index 40f219351..fa6c54247 100644 --- a/server/src/scripts/validate-database.ts +++ b/server/src/scripts/validate-database.ts @@ -129,25 +129,25 @@ async function ValidateScores(): Promise { // process.exit(1); } -async function ValidateCharts(): Promise { +async function ValidateChartsOrSongs(type: "songs" | "charts"): Promise { let globalStart = process.hrtime.bigint(); let globalTotal = 0; let globalSuccess = 0; let globalFail = 0; for (const game of supportedGames) { - let schema = PRUDENCE_CHART_SCHEMAS[game]; + let schema = STATIC_SCHEMAS[type]![game]; let successCount = 0; let total = 0; let fails: { err: PrudenceError; doc: unknown }[] = []; - logger.info(`=== Validating Collection charts (${game}) ... ===`); + logger.info(`=== Validating Collection ${type} (${game}) ... ===`); let start = process.hrtime.bigint(); // eslint-disable-next-line no-await-in-loop - await db.charts[game] + await db[type][game] + // @ts-expect-error whatever bro .find({}, { projection: { _id: 0 } }) - // @ts-expect-error shut UP .each((c: unknown) => { total++; let res = Prudence(c, schema); @@ -167,9 +167,9 @@ async function ValidateCharts(): Promise { if (fails.length !== 0) { logger.severe(`Invalid documents found! Please resolve them.`); - fs.writeFileSync(path.join(BASE_DIR, `charts-${game}.json`), JSON.stringify(fails)); + fs.writeFileSync(path.join(BASE_DIR, `${type}-${game}.json`), JSON.stringify(fails)); fs.writeFileSync( - path.join(BASE_DIR, `charts-${game}.log`), + path.join(BASE_DIR, `${type}-${game}.log`), `Validated ${total} objects. Took ${ Number(end - start) / 1e9 } seconds.\nSuccess: ${successCount} (${((successCount * 100) / total).toFixed( @@ -193,4 +193,4 @@ async function ValidateCharts(): Promise { // ValidateStaticSchemas(); // ValidateScores(); -ValidateCharts(); +ValidateChartsOrSongs("songs");