mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-14 10:09:09 +03:00
update CreateLogCtx
This commit is contained in:
@@ -2,7 +2,7 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import CreateLogCtx from "../../../src/common/logger";
|
||||
import db from "../../../src/db/db";
|
||||
const logger = CreateLogCtx("scripts/__MDB-PARSERS/beatoraja/import.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "./charts.json"), "utf-8"));
|
||||
const songs = JSON.parse(fs.readFileSync(path.join(__dirname, "./songs.json"), "utf-8"));
|
||||
|
||||
@@ -21,7 +21,7 @@ const dataset = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, "./out.json"), "utf-8")
|
||||
) as MDBJson[];
|
||||
|
||||
const logger = CreateLogCtx("diff.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
(async () => {
|
||||
for (const data of dataset) {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("charts-chunithm.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"chunithm:Single">> {
|
||||
let song = await db.songs.chunithm.findOne({
|
||||
const song = await db.songs.chunithm.findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"chunithm:Single">> {
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.chunithm.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.chunithm.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
import { ChartDocument, SongDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
import { oldKTDB } from "./old-db";
|
||||
|
||||
const logger = CreateLogCtx("charts-ddr.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"ddr:SP" | "ddr:DP">> {
|
||||
let song = (await db.songs.ddr.findOne({
|
||||
const song = (await db.songs.ddr.findOne({
|
||||
id: c.id,
|
||||
})) as SongDocument<"ddr">;
|
||||
|
||||
let oldSong = await oldKTDB.get("songs-ddr").findOne({
|
||||
const oldSong = await oldKTDB.get("songs-ddr").findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"ddr:SP" | "ddr:DP">> {
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.ddr.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.ddr.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ChartDocument, SongDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
import { oldKTDB } from "./old-db";
|
||||
|
||||
const logger = CreateLogCtx("charts-gitadora.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"gitadora:Gita" | "gitadora:Dora">> {
|
||||
let song = (await db.songs.gitadora.findOne({
|
||||
const song = (await db.songs.gitadora.findOne({
|
||||
id: c.id,
|
||||
})) as SongDocument<"gitadora">;
|
||||
|
||||
let oldSong = await oldKTDB.get("songs-gitadora").findOne({
|
||||
const oldSong = await oldKTDB.get("songs-gitadora").findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"gitadora:Gita" | "gitad
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.gitadora.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.gitadora.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("charts-iidx.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"iidx:SP" | "iidx:DP">> {
|
||||
let song = await db.songs.iidx.findOne({
|
||||
const song = await db.songs.iidx.findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"iidx:SP" | "iidx:DP">>
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.iidx.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.iidx.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("charts-museca.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"museca:Single">> {
|
||||
let song = await db.songs.museca.findOne({
|
||||
const song = await db.songs.museca.findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"museca:Single">> {
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.museca.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.museca.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ChartDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import { gameOrders } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("charts-sdvx.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<ChartDocument<"sdvx:Single">> {
|
||||
let song = await db.songs.sdvx.findOne({
|
||||
const song = await db.songs.sdvx.findOne({
|
||||
id: c.id,
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ async function ConvertFn(c: any): Promise<ChartDocument<"sdvx:Single">> {
|
||||
versions: [], // sentinel
|
||||
};
|
||||
|
||||
let idx = gameOrders.sdvx.indexOf(song.firstVersion!);
|
||||
const idx = gameOrders.sdvx.indexOf(song.firstVersion!);
|
||||
|
||||
if (idx === -1) {
|
||||
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { FolderDocument, Game } from "kamaitachi-common";
|
||||
import { validPlaytypes, gameHuman } from "kamaitachi-common/js/config";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
import crypto from "crypto";
|
||||
|
||||
const logger = CreateLogCtx("folders.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function ConvertFn(c: any): FolderDocument[] {
|
||||
throw new Error("This doesn't work, It was migrated elsewhere.");
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
import { GoalDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
|
||||
const logger = CreateLogCtx("goals.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function ConvertFn(c: any): GoalDocument | null {
|
||||
let charts: GoalDocument["charts"];
|
||||
@@ -29,7 +29,7 @@ function ConvertFn(c: any): GoalDocument | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
let partialCriteria: Partial<GoalDocument["criteria"]> = {
|
||||
const partialCriteria: Partial<GoalDocument["criteria"]> = {
|
||||
mode: "single",
|
||||
};
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { ICollection } from "monk";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import { oldKTDB } from "./old-db";
|
||||
|
||||
const logger = CreateLogCtx("MIGRATE.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
let newDocuments: unknown[] = [];
|
||||
const newDocuments: unknown[] = [];
|
||||
|
||||
export default async function MigrateRecords(
|
||||
existingCollection: ICollection,
|
||||
collectionName: string,
|
||||
HandlerFN: (c: unknown) => unknown
|
||||
) {
|
||||
let existingRecords = await existingCollection.count({});
|
||||
const existingRecords = await existingCollection.count({});
|
||||
logger.info(`Starting migration for ${collectionName}...`);
|
||||
|
||||
if (existingRecords > 0) {
|
||||
|
||||
@@ -2,13 +2,13 @@ import db from "../../../src/db/db";
|
||||
import { TierlistDataDocument } from "kamaitachi-common";
|
||||
import { CalculateTierlistDataID } from "../../../src/common/tierlist";
|
||||
import { oldKTDB } from "../old-db";
|
||||
import CreateLogCtx from "../../../src/logger";
|
||||
const logger = CreateLogCtx("museca-tierlist.ts");
|
||||
import CreateLogCtx from "../../../src/common/logger";
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const TIERLIST_ID = "ed45403c2cd93922d8a45b3c5bc352a962a8f115";
|
||||
|
||||
function ConvertFn(c: any) {
|
||||
let tdd: TierlistDataDocument<"Individual Difference"> = {
|
||||
const tdd: TierlistDataDocument<"Individual Difference"> = {
|
||||
chartID: c.chartID,
|
||||
type: "score",
|
||||
key: null,
|
||||
@@ -27,7 +27,7 @@ function ConvertFn(c: any) {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let exists = await db["tierlist-data"].count({
|
||||
const exists = await db["tierlist-data"].count({
|
||||
tierlistID: TIERLIST_ID,
|
||||
});
|
||||
|
||||
@@ -36,11 +36,11 @@ function ConvertFn(c: any) {
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
let docs = await oldKTDB.get("tierlistdata").find({
|
||||
const docs = await oldKTDB.get("tierlistdata").find({
|
||||
tierlistID: TIERLIST_ID,
|
||||
});
|
||||
|
||||
let newDocs = await Promise.all(docs.map(ConvertFn));
|
||||
const newDocs = await Promise.all(docs.map(ConvertFn));
|
||||
|
||||
await db["tierlist-data"].insert(newDocs);
|
||||
})();
|
||||
|
||||
@@ -4,10 +4,10 @@ import { PrivateUserDocument, ScoreDocument } from "kamaitachi-common";
|
||||
import { grades, lamps, supportedGames, validPlaytypes } from "kamaitachi-common/js/config";
|
||||
import db from "../../src/db/db";
|
||||
import MigrateRecords from "./migrate";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import { CreateScoreID } from "../../src/score-import/framework/common/score-utils";
|
||||
|
||||
const logger = CreateLogCtx("scores.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
// HERE. WE. GO!
|
||||
|
||||
@@ -31,7 +31,7 @@ function ConvertFn(c: any): ScoreDocument | null {
|
||||
logger.warn(`Ignored game pt ${c.game}, ${c.playtype}`);
|
||||
}
|
||||
|
||||
let base: Omit<ScoreDocument, "scoreID"> = {
|
||||
const base: Omit<ScoreDocument, "scoreID"> = {
|
||||
userID: c.userID,
|
||||
songID: c.songID,
|
||||
playtype: c.scoreData.playtype,
|
||||
@@ -127,9 +127,9 @@ function ConvertFn(c: any): ScoreDocument | null {
|
||||
base.service = "maimagic";
|
||||
}
|
||||
|
||||
let scoreID = CreateScoreID(base.userID, base, base.chartID);
|
||||
const scoreID = CreateScoreID(base.userID, base, base.chartID);
|
||||
|
||||
let score: ScoreDocument = {
|
||||
const score: ScoreDocument = {
|
||||
...base,
|
||||
scoreID,
|
||||
};
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
import { UserGoalDocument } from "kamaitachi-common";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import MigrateRecords from "./migrate";
|
||||
|
||||
const logger = CreateLogCtx("user-goals.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ConvertFn(c: any): Promise<UserGoalDocument | null> {
|
||||
// const newUG: UserGoalDocument = {};
|
||||
|
||||
@@ -7,7 +7,7 @@ import path from "path";
|
||||
// note - this program was never run due to WSL2 errors
|
||||
// causing network requests to screech to a halt.
|
||||
|
||||
const logger = CreateLogCtx("set-indexes.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const program = new Command();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ChartDocument } from "kamaitachi-common";
|
||||
import { FindSongOnTitle } from "../../src/common/database-lookup/song";
|
||||
import { FindChartWithPTDFVersion } from "../../src/common/database-lookup/chart";
|
||||
|
||||
const logger = CreateLogCtx("arc-db-merge.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function MergeIDs() {
|
||||
const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "./charts.json"), "utf-8"));
|
||||
|
||||
@@ -7,20 +7,20 @@ import { FindChartWithPTDF } from "../../src/common/database-lookup/chart";
|
||||
import { Difficulties, TierlistDataDocument } from "kamaitachi-common";
|
||||
|
||||
import { CalculateTierlistDataID } from "../../src/common/tierlist";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
|
||||
const logger = CreateLogCtx("get-sp12-data.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const TIERLIST_ID = "ee9b756e50cff8282091102257b01f423ef855f2";
|
||||
|
||||
async function FetchSP12Data() {
|
||||
let rj = await fetch("https://sp12.iidx.app/api/v1/sheets").then((r) => r.json()); // will throw if somethings wrong, anyway
|
||||
const rj = await fetch("https://sp12.iidx.app/api/v1/sheets").then((r) => r.json()); // will throw if somethings wrong, anyway
|
||||
|
||||
if (!rj.sheets) {
|
||||
throw new Error(`No sheets in return from sp12?`);
|
||||
}
|
||||
|
||||
let tdd: TierlistDataDocument<"Individual Difference">[] = [];
|
||||
const tdd: TierlistDataDocument<"Individual Difference">[] = [];
|
||||
|
||||
for (const sh of rj.sheets) {
|
||||
let chart;
|
||||
@@ -38,7 +38,7 @@ async function FetchSP12Data() {
|
||||
switch (key) {
|
||||
case "NORMAL CLEAR":
|
||||
fakeKey = "n_clear";
|
||||
let v = Math.floor(sh[fakeKey] / 2);
|
||||
const v = Math.floor(sh[fakeKey] / 2);
|
||||
|
||||
if (v === 9) {
|
||||
val = 11.8;
|
||||
@@ -59,7 +59,7 @@ async function FetchSP12Data() {
|
||||
break;
|
||||
case "HARD CLEAR":
|
||||
fakeKey = "hard";
|
||||
let v2 = Math.floor(sh[fakeKey] / 2);
|
||||
const v2 = Math.floor(sh[fakeKey] / 2);
|
||||
|
||||
if (v2 === 9) {
|
||||
val = 11.9;
|
||||
@@ -81,7 +81,7 @@ async function FetchSP12Data() {
|
||||
case "EX HARD CLEAR":
|
||||
fakeKey = "exh";
|
||||
|
||||
let v3 = sh[fakeKey];
|
||||
const v3 = sh[fakeKey];
|
||||
if (v3 < 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ async function FetchSP12Data() {
|
||||
throw new Error("??");
|
||||
}
|
||||
|
||||
let humanised = sh[`${fakeKey}_string`];
|
||||
const humanised = sh[`${fakeKey}_string`];
|
||||
|
||||
if (humanised === "難易度未定") {
|
||||
continue;
|
||||
@@ -152,7 +152,7 @@ async function HumanisedTitleLookup(originalTitle: string) {
|
||||
title = title.split("[")[0];
|
||||
}
|
||||
|
||||
let song = await FindSongOnTitle("iidx", title);
|
||||
const song = await FindSongOnTitle("iidx", title);
|
||||
|
||||
if (!song) {
|
||||
throw new Error(
|
||||
@@ -160,7 +160,7 @@ async function HumanisedTitleLookup(originalTitle: string) {
|
||||
);
|
||||
}
|
||||
|
||||
let chart = await FindChartWithPTDF("iidx", song.id, "SP", difficulty);
|
||||
const chart = await FindChartWithPTDF("iidx", song.id, "SP", difficulty);
|
||||
|
||||
if (!chart) {
|
||||
throw new Error(
|
||||
|
||||
@@ -3,11 +3,11 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import { CalculateTierlistDataID } from "../../src/common/tierlist";
|
||||
import { FindSongOnTitle } from "../../src/common/database-lookup/song";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import { FindChartWithPTDF } from "../../src/common/database-lookup/chart";
|
||||
import { Difficulties } from "kamaitachi-common";
|
||||
|
||||
const logger = CreateLogCtx("parse-iidxkr-data.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const TIERLIST_ID = "ee9b756e50cff8282091102257b01f423ef855f2";
|
||||
|
||||
@@ -16,31 +16,31 @@ async function parseKr(
|
||||
key: "NORMAL CLEAR" | "HARD CLEAR",
|
||||
catVals: { h: string; v: number }[]
|
||||
) {
|
||||
let krdata = JSON.parse(fs.readFileSync(path.join(__dirname, "./iidx-pe-kr", dir), "utf-8"));
|
||||
const krdata = JSON.parse(fs.readFileSync(path.join(__dirname, "./iidx-pe-kr", dir), "utf-8"));
|
||||
|
||||
let tdd = [];
|
||||
const tdd = [];
|
||||
|
||||
for (let i = 0; i < krdata.categories.length; i++) {
|
||||
let data = krdata.categories[i];
|
||||
const data = krdata.categories[i];
|
||||
if (data.sortindex < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let cv = catVals[i];
|
||||
const cv = catVals[i];
|
||||
|
||||
if (!cv) {
|
||||
throw new Error(`cv krdata mismatch ${krdata.categories.length} ${catVals.length}?`);
|
||||
}
|
||||
|
||||
for (const item of data.items) {
|
||||
let song = await FindSongOnTitle("iidx", item.data.title.replace(/†$/u, "").trim());
|
||||
const song = await FindSongOnTitle("iidx", item.data.title.replace(/†$/u, "").trim());
|
||||
|
||||
if (!song) {
|
||||
logger.warn(`Could not find song with title ${item.data.title}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
let t = item.data.type;
|
||||
const t = item.data.type;
|
||||
|
||||
let diff: Difficulties["iidx:SP"];
|
||||
if (t === "A") {
|
||||
@@ -56,7 +56,7 @@ async function parseKr(
|
||||
continue;
|
||||
}
|
||||
|
||||
let chart = await FindChartWithPTDF("iidx", song.id, "SP", diff);
|
||||
const chart = await FindChartWithPTDF("iidx", song.id, "SP", diff);
|
||||
|
||||
if (!chart) {
|
||||
logger.warn(`${song.title} ${diff} - Couldn't find chart?`);
|
||||
@@ -82,7 +82,7 @@ async function parseKr(
|
||||
|
||||
logger.info(`Inserting ${tdd.length} documents...`);
|
||||
|
||||
let x = await db["tierlist-data"].bulkWrite(
|
||||
const x = await db["tierlist-data"].bulkWrite(
|
||||
tdd.map((e) => ({
|
||||
updateOne: {
|
||||
filter: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import db from "../db/db";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("scripts/initialise-counters.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
(async () => {
|
||||
let users = await db.counters.findOne({
|
||||
|
||||
@@ -6,7 +6,7 @@ import CreateLogCtx from "../src/common/logger";
|
||||
|
||||
const program = new Command();
|
||||
|
||||
const logger = CreateLogCtx("save-testdata-from-ktblack.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
program.option("-c, --collection <collection>", "The collection to fetch ktblack data from.");
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { IndexOptions } from "mongodb";
|
||||
import { ValidDatabases } from "kamaitachi-common";
|
||||
import { supportedGames } from "kamaitachi-common/js/config";
|
||||
|
||||
const logger = CreateLogCtx("set-indexes.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const program = new Command();
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import path from "path";
|
||||
import { PRUDENCE_CHART_SCHEMAS } from "../../src/db/schemas";
|
||||
import p from "prudence";
|
||||
import db from "../../src/db/db";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
|
||||
const logger = CreateLogCtx("add-hcnver.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
let data = JSON.parse(fs.readFileSync(path.join(__dirname, "./hcnverdata.json"), "utf-8"));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import CreateLogCtx from "../../../src/common/logger";
|
||||
import db from "../../../src/db/db";
|
||||
|
||||
const logger = CreateLogCtx("scripts/single-use/fix-iidx-versions/stat.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
(async () => {
|
||||
const charts = await db.charts.iidx.find({ versions: { $size: 0 } });
|
||||
|
||||
@@ -4,7 +4,7 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import CreateLogCtx from "../../../src/common/logger";
|
||||
import { FindSongOnTitleInsensitive } from "../../../src/common/database-lookup/song";
|
||||
const logger = CreateLogCtx("scripts/single-use/fix-iidx-versions/update-versions.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const comicallyLargeJSONData = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, "./versions.json"), "utf-8")
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import parser from "fast-xml-parser";
|
||||
import CreateLogCtx from "../../src/logger";
|
||||
import CreateLogCtx from "../../src/common/logger";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const logger = CreateLogCtx("s3check.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
let parsedXML;
|
||||
|
||||
let fileData = fs.readFileSync(
|
||||
const fileData = fs.readFileSync(
|
||||
path.join(__dirname, "../../src/test-utils/test-data/s3/valid.xml"),
|
||||
"utf-8"
|
||||
);
|
||||
|
||||
@@ -10,10 +10,10 @@ import {
|
||||
FindChartWithPTDFVersion,
|
||||
} from "../src/score-import/database-lookup/chart-ptdf";
|
||||
import db from "../src/db/db";
|
||||
import CreateLogCtx from "../src/logger";
|
||||
import CreateLogCtx from "../src/common/logger";
|
||||
const program = new Command();
|
||||
|
||||
const logger = CreateLogCtx("update-bpi-poyashi.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
program.option("-f, --fetch", "Fetch the latest data from the poyashi repo.");
|
||||
|
||||
@@ -36,7 +36,7 @@ async function UpdatePoyashiData() {
|
||||
if (options.fetch) {
|
||||
// lol!
|
||||
logger.info("Fetching data from github...");
|
||||
let rj = await fetch(
|
||||
const rj = await fetch(
|
||||
"https://raw.githubusercontent.com/potakusan/bpim-score-repo/master/output/release.json"
|
||||
).then((r) => r.json());
|
||||
|
||||
@@ -50,7 +50,7 @@ async function UpdatePoyashiData() {
|
||||
data = JSON.parse(fs.readFileSync(dataLoc, "utf-8"));
|
||||
}
|
||||
|
||||
let realData: IIDXBPIData[] = [];
|
||||
const realData: IIDXBPIData[] = [];
|
||||
for (const d of data.body) {
|
||||
const res = difficultyResolve[d.difficulty];
|
||||
|
||||
@@ -60,14 +60,14 @@ async function UpdatePoyashiData() {
|
||||
|
||||
const [playtype, diff] = res;
|
||||
|
||||
let ktchiSong = await FindSongOnTitle("iidx", d.title);
|
||||
const ktchiSong = await FindSongOnTitle("iidx", d.title);
|
||||
|
||||
if (!ktchiSong) {
|
||||
logger.warn(`Cannot find song ${d.title}?`);
|
||||
continue;
|
||||
}
|
||||
|
||||
let ktchiChart = (await FindChartWithPTDFVersion(
|
||||
const ktchiChart = (await FindChartWithPTDFVersion(
|
||||
"iidx",
|
||||
ktchiSong.id,
|
||||
playtype as "SP" | "DP",
|
||||
@@ -82,7 +82,7 @@ async function UpdatePoyashiData() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let kavg = Number(d.avg);
|
||||
const kavg = Number(d.avg);
|
||||
|
||||
if (kavg < 0) {
|
||||
logger.warn(
|
||||
@@ -91,7 +91,7 @@ async function UpdatePoyashiData() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let kesd = ESDCore.CalculateESD(
|
||||
const kesd = ESDCore.CalculateESD(
|
||||
config.judgementWindows.iidx.SP,
|
||||
kavg / (ktchiChart.data.notecount * 2)
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Prudence, { PrudenceSchema } from "prudence";
|
||||
import db from "../src/db/db";
|
||||
import { PRUDENCE_CHART_SCHEMAS, PRUDENCE_SCORE_SCHEMAS, STATIC_SCHEMAS } from "../src/db/schemas";
|
||||
import CreateLogCtx from "../src/logger";
|
||||
import CreateLogCtx from "../src/common/logger";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { PrudenceError } from "prudence/js/error";
|
||||
@@ -12,7 +12,7 @@ const BASE_DIR = path.join(__dirname, "./validate-database-errs");
|
||||
// note: a hell of a lot of this code is copy pasted
|
||||
// this is just a script, so, feel free to refactor it.
|
||||
|
||||
const logger = CreateLogCtx("validate-database.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function ValidateStaticSchemas(): Promise<void> {
|
||||
for (const x in STATIC_SCHEMAS) {
|
||||
@@ -24,15 +24,15 @@ async function ValidateStaticSchemas(): Promise<void> {
|
||||
|
||||
let successCount = 0;
|
||||
let total = 0;
|
||||
let fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
const fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
|
||||
let start = process.hrtime.bigint();
|
||||
const start = process.hrtime.bigint();
|
||||
|
||||
// @ts-expect-error shut UP
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await db[c].find({}, { projection: { _id: 0 } }).each((c: unknown) => {
|
||||
total++;
|
||||
let res = Prudence(c, schema);
|
||||
const res = Prudence(c, schema);
|
||||
|
||||
if (res === null) {
|
||||
successCount++;
|
||||
@@ -42,7 +42,7 @@ async function ValidateStaticSchemas(): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
let end = process.hrtime.bigint();
|
||||
const end = process.hrtime.bigint();
|
||||
logger.info(`Validated ${total} objects. Took ${Number(end - start) / 1e9} seconds.`);
|
||||
logger.info(`Success: ${successCount} (${((successCount * 100) / total).toFixed(2)}%)`);
|
||||
logger.info(`Fail: ${fails.length} (${((fails.length * 100) / total).toFixed(2)}%)`);
|
||||
@@ -58,21 +58,21 @@ async function ValidateStaticSchemas(): Promise<void> {
|
||||
}
|
||||
|
||||
async function ValidateScores(): Promise<void> {
|
||||
let globalStart = process.hrtime.bigint();
|
||||
const globalStart = process.hrtime.bigint();
|
||||
let globalTotal = 0;
|
||||
let globalSuccess = 0;
|
||||
let globalFail = 0;
|
||||
for (const game of supportedGames) {
|
||||
for (const playtype of validPlaytypes[game]) {
|
||||
// @ts-expect-error shut up
|
||||
let schema = PRUDENCE_SCORE_SCHEMAS[game][playtype];
|
||||
const schema = PRUDENCE_SCORE_SCHEMAS[game][playtype];
|
||||
|
||||
let successCount = 0;
|
||||
let total = 0;
|
||||
let fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
const fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
|
||||
logger.info(`=== Validating Collection scores (${game} ${playtype}) ... ===`);
|
||||
let start = process.hrtime.bigint();
|
||||
const start = process.hrtime.bigint();
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await db.scores
|
||||
@@ -80,7 +80,7 @@ async function ValidateScores(): Promise<void> {
|
||||
// @ts-expect-error shut UP
|
||||
.each((c: unknown) => {
|
||||
total++;
|
||||
let res = Prudence(c, schema);
|
||||
const res = Prudence(c, schema);
|
||||
|
||||
if (res === null) {
|
||||
successCount++;
|
||||
@@ -92,7 +92,7 @@ async function ValidateScores(): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
let end = process.hrtime.bigint();
|
||||
const end = process.hrtime.bigint();
|
||||
logger.info(`Validated ${total} objects. Took ${Number(end - start) / 1e9} seconds.`);
|
||||
logger.info(`Success: ${successCount} (${((successCount * 100) / total).toFixed(2)}%)`);
|
||||
logger.info(`Fail: ${fails.length} (${((fails.length * 100) / total).toFixed(2)}%)`);
|
||||
@@ -119,7 +119,7 @@ async function ValidateScores(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
let globalEnd = process.hrtime.bigint();
|
||||
const globalEnd = process.hrtime.bigint();
|
||||
logger.info(
|
||||
`Validated ${globalTotal} objects. Took ${Number(globalEnd - globalStart) / 1e9} seconds.`
|
||||
);
|
||||
@@ -130,19 +130,19 @@ async function ValidateScores(): Promise<void> {
|
||||
}
|
||||
|
||||
async function ValidateChartsOrSongs(type: "songs" | "charts"): Promise<void> {
|
||||
let globalStart = process.hrtime.bigint();
|
||||
const globalStart = process.hrtime.bigint();
|
||||
let globalTotal = 0;
|
||||
let globalSuccess = 0;
|
||||
let globalFail = 0;
|
||||
for (const game of supportedGames) {
|
||||
let schema = STATIC_SCHEMAS[type]![game];
|
||||
const schema = STATIC_SCHEMAS[type]![game];
|
||||
|
||||
let successCount = 0;
|
||||
let total = 0;
|
||||
let fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
const fails: { err: PrudenceError; doc: unknown }[] = [];
|
||||
|
||||
logger.info(`=== Validating Collection ${type} (${game}) ... ===`);
|
||||
let start = process.hrtime.bigint();
|
||||
const start = process.hrtime.bigint();
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await db[type][game]
|
||||
@@ -150,7 +150,7 @@ async function ValidateChartsOrSongs(type: "songs" | "charts"): Promise<void> {
|
||||
.find({}, { projection: { _id: 0 } })
|
||||
.each((c: unknown) => {
|
||||
total++;
|
||||
let res = Prudence(c, schema);
|
||||
const res = Prudence(c, schema);
|
||||
|
||||
if (res === null) {
|
||||
successCount++;
|
||||
@@ -160,7 +160,7 @@ async function ValidateChartsOrSongs(type: "songs" | "charts"): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
let end = process.hrtime.bigint();
|
||||
const end = process.hrtime.bigint();
|
||||
logger.info(`Validated ${total} objects. Took ${Number(end - start) / 1e9} seconds.`);
|
||||
logger.info(`Success: ${successCount} (${((successCount * 100) / total).toFixed(2)}%)`);
|
||||
logger.info(`Fail: ${fails.length} (${((fails.length * 100) / total).toFixed(2)}%)`);
|
||||
@@ -183,7 +183,7 @@ async function ValidateChartsOrSongs(type: "songs" | "charts"): Promise<void> {
|
||||
globalSuccess += successCount;
|
||||
}
|
||||
|
||||
let globalEnd = process.hrtime.bigint();
|
||||
const globalEnd = process.hrtime.bigint();
|
||||
logger.info(
|
||||
`Validated ${globalTotal} objects. Took ${Number(globalEnd - globalStart) / 1e9} seconds.`
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ import CreateLogCtx from "../../common/logger";
|
||||
import prValidate from "../../middleware/prudence-validate";
|
||||
import { RequireLoggedIn } from "../../middleware/require-logged-in";
|
||||
|
||||
const logger = CreateLogCtx("auth.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ t.test("POST /api/import/file", async (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.skip("file/solid-state-squad", (t) => {
|
||||
t.test("file/solid-state-squad", (t) => {
|
||||
t.beforeEach(LoadKTBlackIIDXData);
|
||||
|
||||
t.test("Large Import", async (t) => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { KtLogger } from "../../types";
|
||||
import { ExpressWrappedScoreImportMain } from "../../score-import/framework/express-wrapper";
|
||||
import { CreateMulterSingleUploadMiddleware } from "../../common/multer";
|
||||
|
||||
const logger = CreateLogCtx("import.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import ParseDirectManual from "../../../score-import/import-types/ir/direct-manu
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
const logger = CreateLogCtx("direct-manual.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
/**
|
||||
* Imports scores in ir/json:direct-manual form.
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Playtypes } from "kamaitachi-common";
|
||||
import CreateLogCtx from "../../../common/logger";
|
||||
import { FERVIDEX_COURSE_LOOKUP } from "../../../score-import/import-types/ir/fervidex-static/class-handler";
|
||||
|
||||
const logger = CreateLogCtx("fervidex.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MStoS } from "../../../common/util";
|
||||
import { USCIR_ADJACENT_SCORE_N } from "../../../constants/usc-ir";
|
||||
import db from "../../../db/db";
|
||||
|
||||
const logger = CreateLogCtx("ir/usc/common.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export interface USCServerScore {
|
||||
score: integer;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ParseIRUSC } from "../../../score-import/import-types/ir/usc/parser";
|
||||
import { USCIR_MAX_LEADERBOARD_N } from "../../../constants/usc-ir";
|
||||
import { CreateMulterSingleUploadMiddleware } from "../../../common/multer";
|
||||
|
||||
const logger = CreateLogCtx("usc.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import { FormatUserDoc } from "./user";
|
||||
import nodeFetch from "./fetch";
|
||||
import { CAPTCHA_SECRET_KEY } from "../secrets";
|
||||
|
||||
const logger = CreateLogCtx("auth.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const BCRYPT_SALT_ROUNDS = 12;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ClassData, gameClassValues } from "kamaitachi-common/js/game-classes";
|
||||
import db from "../db/db";
|
||||
import CreateLogCtx from "./logger";
|
||||
|
||||
const logger = CreateLogCtx("class.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export function GetClassSetsForGamePT(game: Game, playtype: Playtypes[Game]) {
|
||||
// @ts-expect-error its confused about game+pt permutations
|
||||
|
||||
@@ -64,6 +64,7 @@ export function FindDDRChartOnSongHash(
|
||||
"data.songHash": songHash,
|
||||
playtype,
|
||||
difficulty,
|
||||
isPrimary: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,11 +105,10 @@ export function FindIIDXChartOnInGameID(
|
||||
playtype: Playtypes[Game],
|
||||
difficulty: Difficulties[IDStrings]
|
||||
) {
|
||||
// @todo #101 throw an error if this is called with a game that doesn't
|
||||
// support InGameID.
|
||||
return db.charts.iidx.findOne({
|
||||
"data.inGameID": inGameID,
|
||||
"flags.2dxtra": false,
|
||||
isPrimary: true,
|
||||
playtype,
|
||||
difficulty,
|
||||
});
|
||||
@@ -180,6 +180,7 @@ export function FindSDVXChartOnInGameID(
|
||||
return db.charts.sdvx.findOne({
|
||||
"data.inGameID": inGameID,
|
||||
difficulty: diffQuery,
|
||||
isPrimary: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import db from "../db/db";
|
||||
import CreateLogCtx from "./logger";
|
||||
const logger = CreateLogCtx("db.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
import { integer } from "kamaitachi-common";
|
||||
|
||||
export async function GetNextCounterValue(counterName: string): Promise<integer> {
|
||||
|
||||
@@ -12,7 +12,7 @@ import db, { CloseMongoConnection } from "../db/db";
|
||||
import ResetDBState from "../test-utils/reset-db-state";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("folder.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.todo("#CreateFolderChartLookup");
|
||||
t.todo("#GetFolderCharts");
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FolderDocument, AnyChartDocument, AnySongDocument } from "kamaitachi-co
|
||||
import { FilterQuery } from "mongodb";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("folder.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
// overloads!
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "../test-utils/test-data";
|
||||
import { CreateFolderChartLookup } from "./folder";
|
||||
|
||||
const logger = CreateLogCtx("goal.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#EvaluateGoalForUser", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CloseMongoConnection } from "../db/db";
|
||||
import CreateLogCtx, { Transports } from "./logger";
|
||||
|
||||
t.test("Logger Tests", (t) => {
|
||||
const logger = CreateLogCtx("logger.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
Transports[2].level = "debug"; // lol
|
||||
|
||||
|
||||
@@ -138,8 +138,10 @@ export const rootLogger = winston.createLogger({
|
||||
transports: tports,
|
||||
});
|
||||
|
||||
function CreateLogCtx(context: string, lg = rootLogger): KtLogger {
|
||||
return lg.child({ context }) as KtLogger;
|
||||
function CreateLogCtx(__filename): KtLogger {
|
||||
return lg.child({
|
||||
context: filename.replace(new RegExp(`^${process.cwd()}/`, "u"), ""),
|
||||
}) as KtLogger;
|
||||
}
|
||||
|
||||
export function AppendLogCtx(context: string, lg: KtLogger): KtLogger {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { RequestHandler } from "express";
|
||||
import multer, { MulterError } from "multer";
|
||||
import CreateLogCtx from "./logger";
|
||||
|
||||
const defaultLogger = CreateLogCtx("multer.ts");
|
||||
const defaultLogger = CreateLogCtx(__filename);
|
||||
|
||||
export const DefaultMulterUpload = multer({ limits: { fileSize: 1024 * 1024 * 16 } }); // 16MB
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { AnyChartDocument, Game, Playtypes } from "kamaitachi-common";
|
||||
import db from "../db/db";
|
||||
import CreateLogCtx from "./logger";
|
||||
|
||||
const logger = CreateLogCtx("tierlist.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export function CalculateTierlistDataID(
|
||||
chartID: string,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { FindOneResult } from "monk";
|
||||
import db from "../db/db";
|
||||
import CreateLogCtx from "./logger";
|
||||
|
||||
const logger = CreateLogCtx("user.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const OMIT_PRIVATE_USER_RETURNS = {
|
||||
password: 0,
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import {
|
||||
import monk from "monk";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("db.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const base = process.env.MONGO_BASE_URL ?? "127.0.0.1";
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const logger = CreateLogCtx("main.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
logger.info(`Booting Kamaitachi BLACK - ${FormatVersion()} [ENV: ${process.env.NODE_ENV}]`);
|
||||
logger.info(`Log level on ${process.env.LOG_LEVEL ?? "info"}.`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Prudence, { MiddlewareErrorHandler } from "prudence";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("prudence-validate.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const printf = (message: string, stringVal: string | null, keychain: string | null) =>
|
||||
`${message}${stringVal ? ` (Received ${stringVal})` : ""} [K:${keychain}]`;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("require-logged-in.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export function RequireLoggedIn(req: Request, res: Response, next: NextFunction) {
|
||||
if (!req.session.ktchi?.userID) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import expressSession from "express-session";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
import redis from "redis";
|
||||
|
||||
const logger = CreateLogCtx("redis-store.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export const RedisStore = connectRedis(expressSession);
|
||||
logger.verbose("Instantiated Redis Store");
|
||||
|
||||
@@ -14,7 +14,7 @@ import deepmerge from "deepmerge";
|
||||
import ResetDBState from "../../../test-utils/reset-db-state";
|
||||
import { GetDefaultTierlist } from "../../../common/tierlist";
|
||||
|
||||
const mockLogger = CreateLogCtx("calculated-data.test.ts");
|
||||
const mockLogger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#CreateCalculatedData", async (t) => {
|
||||
const res = await CreateCalculatedData(TestingIIDXSPDryScore, Testing511SPA, 30, mockLogger);
|
||||
|
||||
@@ -127,7 +127,7 @@ t.test("#CalculateKESDC", (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
const mockLogger = CreateLogCtx("game-specific-stats.test.ts");
|
||||
const mockLogger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#CalculateMFCP", (t) => {
|
||||
function TestMFCP(
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
TestingSDVXSingleDryScore,
|
||||
} from "../../../test-utils/test-data";
|
||||
import { CreateGameSpecific } from "./game-specific";
|
||||
const logger = CreateLogCtx("fake-testing-context");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
/**
|
||||
* These tests only check that the right properties are assigned.
|
||||
|
||||
@@ -13,7 +13,7 @@ import { judgementWindows, gamePercentMax } from "kamaitachi-common/js/config";
|
||||
import CreateLogCtx from "../../../common/logger";
|
||||
import { InternalFailure, InvalidScoreFailure } from "./converter-failures";
|
||||
|
||||
const logger = CreateLogCtx("score-utils.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
/**
|
||||
* Util for getting a games' grade for a given percent.
|
||||
|
||||
@@ -22,7 +22,7 @@ import deepmerge from "deepmerge";
|
||||
import CreateLogCtx from "../../../common/logger";
|
||||
import crypto from "crypto";
|
||||
|
||||
const logger = CreateLogCtx("goals.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#GetRelevantFolderGoals", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { UpdateUsersMilestones } from "./milestones";
|
||||
import { GoalImportInfo } from "kamaitachi-common";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("milestones.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function CreateMockGII(...garr: [string, boolean][]) {
|
||||
return (garr.map((e) => ({
|
||||
|
||||
@@ -10,7 +10,7 @@ import { lamps } from "kamaitachi-common/js/config";
|
||||
|
||||
let IIDXScore = TestingIIDXSPScore;
|
||||
|
||||
const logger = CreateLogCtx("create-pb-doc.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#CreatePBDoc", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ProcessPBs } from "./process-pbs";
|
||||
import deepmerge from "deepmerge";
|
||||
import crypto from "crypto";
|
||||
|
||||
const logger = CreateLogCtx("process-pbs.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#ProcessPBs", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ScoreDocument } from "kamaitachi-common";
|
||||
import db from "../../../db/db";
|
||||
import CreateLogCtx from "../../../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("insert-score.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
const ScoreQueue: ScoreDocument[] = [];
|
||||
export let ScoreIDs: Set<string> = new Set();
|
||||
const MAX_PIPELINE_LENGTH = 500;
|
||||
|
||||
@@ -5,7 +5,7 @@ import CreateLogCtx from "../../../common/logger";
|
||||
import ResetDBState from "../../../test-utils/reset-db-state";
|
||||
import { CalculateClassDeltas, UpdateUGSClasses } from "./classes";
|
||||
|
||||
const logger = CreateLogCtx("classes.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#UpdateUGSClasses", (t) => {
|
||||
t.test("Should produce an empty object by default", async (t) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import deepmerge from "deepmerge";
|
||||
import CreateLogCtx from "../../../common/logger";
|
||||
import crypto from "crypto";
|
||||
|
||||
const logger = CreateLogCtx("rating.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#CalculateRatings", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -8,7 +8,7 @@ import deepmerge from "deepmerge";
|
||||
import crypto from "crypto";
|
||||
import { TestingIIDXSPScorePB } from "../../../test-utils/test-data";
|
||||
|
||||
const logger = CreateLogCtx("update-ugs.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
// more of an integration test
|
||||
t.test("#UpdateUsersGamePlaytypeStats", (t) => {
|
||||
|
||||
@@ -32,7 +32,7 @@ const ktdWrap = (msg: string, game: Game = "iidx", version = null): any => ({
|
||||
data: {}, // any under t.match rules.
|
||||
});
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const importType = "file/batch-manual" as const;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const mockErr = (...msg: string[]) =>
|
||||
name: "Error",
|
||||
} as unknown) as ScoreImportFatalError);
|
||||
|
||||
const logger = CreateLogCtx("parser.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const baseBatchManual = {
|
||||
body: [],
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
KTDataNotFoundFailure,
|
||||
} from "../../../framework/common/converter-failures";
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const chartID511 = "c2311194e3897ddb5745b1760d2c0141f933e683";
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../../../../test-utils/test-data";
|
||||
import { MockMulterFile } from "../../../../test-utils/mock-multer";
|
||||
|
||||
const logger = CreateLogCtx("parser.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#ParseEamusementCSV", (t) => {
|
||||
t.test("Valid Rootage-Type CSV", (t) => {
|
||||
@@ -18,9 +18,9 @@ t.test("#ParseEamusementCSV", (t) => {
|
||||
logger
|
||||
);
|
||||
|
||||
t.equal(iterableData.length, 839, "Should return exactly 839 datapoints.");
|
||||
t.equal(iterableData.length, 152, "Should return exactly 152 datapoints.");
|
||||
t.equal(hasBeginnerAndLegg, false, "Should not mark as a HV csv.");
|
||||
t.equal(version, "23", "Should correctly assert that the version of this CSV is copula.");
|
||||
t.equal(version, "26", "Should correctly assert that the version of this CSV is ROOTAGE.");
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -243,7 +243,7 @@ function GenericParseEamIIDXCSV(
|
||||
(lowercaseFilename.includes("dp") && playtype === "SP"))
|
||||
) {
|
||||
logger.info(
|
||||
`File was uploaded with filename ${fileData.filename}, but this was set as a ${playtype} import. Sanity check refusing.`
|
||||
`File was uploaded with filename ${fileData.originalname}, but this was set as a ${playtype} import. Sanity check refusing.`
|
||||
);
|
||||
|
||||
throw new ScoreImportFatalError(
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ConvertFileMerIIDX } from "./converter";
|
||||
import deepmerge from "deepmerge";
|
||||
import { MerScore } from "./types";
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#ConvertFileMerIIDX", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { GetKTDataBuffer, GetKTDataJSON } from "../../../../test-utils/test-data
|
||||
import { ParseMerIIDX } from "./parser";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("parser.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#ParseMerIIDX", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -3,12 +3,17 @@ import t from "tap";
|
||||
import db, { CloseMongoConnection } from "../../../../db/db";
|
||||
import CreateLogCtx from "../../../../common/logger";
|
||||
import ResetDBState from "../../../../test-utils/reset-db-state";
|
||||
import { GetKTDataJSON, Testing511Song, Testing511SPA } from "../../../../test-utils/test-data";
|
||||
import {
|
||||
GetKTDataJSON,
|
||||
LoadKTBlackIIDXData,
|
||||
Testing511Song,
|
||||
Testing511SPA,
|
||||
} from "../../../../test-utils/test-data";
|
||||
import { ConvertFileS3, ParseDifficulty, ResolveS3Lamp } from "./converter";
|
||||
import { S3Score } from "./types";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function cfile(data: S3Score) {
|
||||
return ConvertFileS3(data, {}, "file/solid-state-squad", logger);
|
||||
@@ -82,19 +87,15 @@ t.test("#ConvertFileS3", (t) => {
|
||||
});
|
||||
|
||||
t.test("Should find song case-insensitively", async (t) => {
|
||||
await db.charts.iidx.remove({});
|
||||
await db.charts.iidx.insert(GetKTDataJSON("./kamaitachi/ktblack-charts-iidx.json"));
|
||||
await LoadKTBlackIIDXData();
|
||||
|
||||
await db.songs.iidx.remove({});
|
||||
await db.songs.iidx.insert(GetKTDataJSON("./kamaitachi/ktblack-songs-iidx.json"));
|
||||
|
||||
const res = await mfile({ songname: "gamBOL", diff: 7 });
|
||||
const res = await mfile({ songname: "aBSolUte", diff: 7 });
|
||||
|
||||
t.hasStrict(
|
||||
res,
|
||||
{
|
||||
chart: { songID: 7, difficulty: "HYPER", playtype: "SP" },
|
||||
song: { title: "GAMBOL" },
|
||||
chart: { songID: 97, difficulty: "HYPER", playtype: "SP" },
|
||||
song: { title: "ABSOLUTE" },
|
||||
// dryScore, dont care
|
||||
} as any,
|
||||
"Should correctly return the song, chart and DryScore."
|
||||
@@ -161,7 +162,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
|
||||
t.test("Should throw an invalidscore if the exscore is greater than MAX", (t) => {
|
||||
t.rejects(mfile({ exscore: 10000 }), {
|
||||
message: /Percent was greater than 100%/u,
|
||||
message: /Invalid percent of 636/u,
|
||||
} as any);
|
||||
|
||||
t.end();
|
||||
@@ -169,7 +170,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
|
||||
t.test("Should throw an invalidscore if the date is invalid.", (t) => {
|
||||
t.rejects(mfile({ date: "INVALID" }), {
|
||||
message: /Invalid timestamp of INVALID - could not parse/u,
|
||||
message: /Invalid\/Unparsable score timestamp of INVALID/u,
|
||||
} as any);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -8,7 +8,7 @@ import ResetDBState from "../../../../test-utils/reset-db-state";
|
||||
import { GetKTDataBuffer } from "../../../../test-utils/test-data";
|
||||
import { ParseSolidStateXML } from "./parser";
|
||||
|
||||
const logger = CreateLogCtx("parser.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#ParseSolidStateXML", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import { FervidexScore } from "./types";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.test("#SplitFervidexChartRef", (t) => {
|
||||
t.strictSame(SplitFervidexChartRef("spb"), { playtype: "SP", difficulty: "BEGINNER" });
|
||||
|
||||
@@ -6,7 +6,7 @@ import { SESSION_SECRET } from "./secrets";
|
||||
import { integer } from "kamaitachi-common";
|
||||
import { RedisClient, RedisStore } from "./redis/redis-store";
|
||||
|
||||
const logger = CreateLogCtx("server.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const userSessionMiddleware = expressSession({
|
||||
// append node_env onto the end of the session name
|
||||
|
||||
@@ -2,7 +2,7 @@ import ResetDBState from "./reset-db-state";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
import supertest from "supertest";
|
||||
|
||||
const logger = CreateLogCtx("fake-session.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export async function CreateFakeAuthCookie(mockApi: supertest.SuperTest<supertest.Test>) {
|
||||
await ResetDBState();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import supertest from "supertest";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("mock-api.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
import server from "../server";
|
||||
|
||||
|
||||
@@ -1,55 +1,36 @@
|
||||
[
|
||||
{
|
||||
"chartID": "c2311194e3897ddb5745b1760d2c0141f933e683",
|
||||
"rgcID": null,
|
||||
"chartID": "c2311194e3897ddb5745b1760d2c0141f933e683",
|
||||
"difficulty": "ANOTHER",
|
||||
"songID": 1,
|
||||
"playtype": "SP",
|
||||
"levelNum": 10,
|
||||
"level": "10",
|
||||
"difficulty": "ANOTHER",
|
||||
"playtype": "SP",
|
||||
"songID": 1,
|
||||
"flags": {
|
||||
"2dxtra": false,
|
||||
"IN BASE GAME": true,
|
||||
"OMNIMIX": true,
|
||||
"N-1": true
|
||||
"N-1": true,
|
||||
"2dxtra": false
|
||||
},
|
||||
"data": {
|
||||
"notecount": 786,
|
||||
"inGameID": 1000,
|
||||
"hashSHA256": null,
|
||||
"arcChartID": null,
|
||||
"2dxtraSet": null
|
||||
"notecount": 786,
|
||||
"arcChartID": "CYjwAuz7Yq9"
|
||||
},
|
||||
"isPrimary": true,
|
||||
"versions": ["0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
"17",
|
||||
"18",
|
||||
"19",
|
||||
"20",
|
||||
"21",
|
||||
"22",
|
||||
"23",
|
||||
"24",
|
||||
"25",
|
||||
"26",
|
||||
"versions": [
|
||||
"27-omni",
|
||||
"26-omni",
|
||||
"27",
|
||||
"28"
|
||||
"26",
|
||||
"inf",
|
||||
"16-cs",
|
||||
"12-cs",
|
||||
"10-cs",
|
||||
"8-cs",
|
||||
"7-cs",
|
||||
"bmus"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -6,37 +6,6 @@
|
||||
"firstVersion": "0",
|
||||
"alt-titles": [],
|
||||
"search-titles": [],
|
||||
"versions": [
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
"17",
|
||||
"18",
|
||||
"19",
|
||||
"20",
|
||||
"21",
|
||||
"22",
|
||||
"23",
|
||||
"24",
|
||||
"25",
|
||||
"26",
|
||||
"27",
|
||||
"28"
|
||||
],
|
||||
"data": {
|
||||
"genre": "PIANO AMBIENT"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import CreateLogCtx from "../common/logger";
|
||||
|
||||
const logger = CreateLogCtx("reset-db-state.ts");
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const DATA_DIR = path.join(__dirname, "./mock-db");
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "6088306a65303f57143cab68"
|
||||
},
|
||||
"rgcID": null,
|
||||
"chartID": "c2311194e3897ddb5745b1760d2c0141f933e683",
|
||||
"difficulty": "ANOTHER",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
"id": 187,
|
||||
"diff": "A",
|
||||
"songname": "5.1.1.",
|
||||
"styles": "3rd",
|
||||
"styles": "7th",
|
||||
"exscore": 100,
|
||||
"scorebreakdown": {
|
||||
"justgreats": 25,
|
||||
|
||||
Reference in New Issue
Block a user