mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 21:08:09 +03:00
tierlist-core
This commit is contained in:
Generated
+3
-3
@@ -62,7 +62,7 @@ dependencies:
|
||||
express-async-errors: 3.1.1_express@4.17.1
|
||||
express-session: 1.17.1
|
||||
fast-json-stable-hash: 1.0.1
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/e7a539900ee048b264de96fab373b03c571bd411
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/1bb739cd22c64977bdb542d112836019447d95bc
|
||||
mongodb: 3.6.6
|
||||
monk: 7.3.4
|
||||
multer: 1.4.2
|
||||
@@ -4638,8 +4638,8 @@ packages:
|
||||
'@types/yoga-layout': 1.9.2
|
||||
dev: true
|
||||
|
||||
github.com/zkldi/Kamaitachi-common/e7a539900ee048b264de96fab373b03c571bd411:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/e7a539900ee048b264de96fab373b03c571bd411}
|
||||
github.com/zkldi/Kamaitachi-common/1bb739cd22c64977bdb542d112836019447d95bc:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/1bb739cd22c64977bdb542d112836019447d95bc}
|
||||
name: kamaitachi-common
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import db from "../../../src/db/db";
|
||||
import { TierlistDataDocument } from "kamaitachi-common";
|
||||
import { CalculateTierlistDataID } from "../../../src/core/tierlist-core";
|
||||
import { oldKTDB } from "../old-db";
|
||||
import CreateLogCtx from "../../../src/logger";
|
||||
const logger = CreateLogCtx("museca-tierlist.ts");
|
||||
|
||||
const TIERLIST_ID = "ed45403c2cd93922d8a45b3c5bc352a962a8f115";
|
||||
|
||||
function ConvertFn(c: any) {
|
||||
let tdd: TierlistDataDocument<"Individual Difference"> = {
|
||||
chartID: c.chartID,
|
||||
type: "score",
|
||||
key: null,
|
||||
tierlistDataID: CalculateTierlistDataID(c.chartID, "score", null, TIERLIST_ID),
|
||||
tierlistID: TIERLIST_ID,
|
||||
data: {
|
||||
flags: {
|
||||
"Individual Difference": c.idvDifference === "FALSE",
|
||||
},
|
||||
value: c.tiers["score-tier"],
|
||||
humanised: `☆${c.tiers["score-tier"]}`,
|
||||
},
|
||||
};
|
||||
|
||||
return tdd;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let exists = await db["tierlist-data"].count({
|
||||
tierlistID: TIERLIST_ID,
|
||||
});
|
||||
|
||||
if (exists > 0) {
|
||||
logger.error(`Cancelling migration request as ${exists} documents already exist.`);
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
let docs = await oldKTDB.get("tierlistdata").find({
|
||||
tierlistID: TIERLIST_ID,
|
||||
});
|
||||
|
||||
let newDocs = await Promise.all(docs.map(ConvertFn));
|
||||
|
||||
await db["tierlist-data"].insert(newDocs);
|
||||
})();
|
||||
@@ -47,6 +47,12 @@ const indexes: Partial<Record<ValidDatabases, Index[]>> = {
|
||||
],
|
||||
"game-stats": [index({ userID: 1, game: 1, playtype: 1 }, UNIQUE)],
|
||||
"folder-chart-lookup": [index({ chartID: 1, folderID: 1 }, UNIQUE)],
|
||||
"tierlist-data": [
|
||||
index({ tierlistDataID: 1 }, UNIQUE),
|
||||
index({ chartID: 1, tierlistID: 1 }),
|
||||
index({ chartID: 1, tierlistID: 1, type: 1 }),
|
||||
index({ chartID: 1, tierlistID: 1, type: 1, key: 1 }, UNIQUE),
|
||||
],
|
||||
};
|
||||
|
||||
(async () => {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
export function CalculateTierlistDataID(
|
||||
chartID: string,
|
||||
type: "score" | "lamp" | "grade",
|
||||
key: string | null,
|
||||
tierlistID: string
|
||||
) {
|
||||
return crypto
|
||||
.createHash("sha256")
|
||||
.update(`${chartID}|${type}|${key}|${tierlistID}`)
|
||||
.digest("hex");
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ImportDocument,
|
||||
TierlistParent,
|
||||
InviteCodeDocument,
|
||||
TierlistDataDocument,
|
||||
MilestoneDocument,
|
||||
NotificationDocument,
|
||||
FolderChartLookup,
|
||||
@@ -96,6 +97,7 @@ const db = {
|
||||
charts,
|
||||
scores: monkDB.get<ScoreDocument>("scores"),
|
||||
tierlists: monkDB.get<TierlistParent>("tierlists"),
|
||||
"tierlist-data": monkDB.get<TierlistDataDocument<never>>("tierlist-data"),
|
||||
"score-pbs": monkDB.get<PBScoreDocument>("score-pbs"),
|
||||
folders: monkDB.get<FolderDocument>("folders"),
|
||||
"folder-chart-lookup": monkDB.get<FolderChartLookup>("folder-chart-lookup"),
|
||||
|
||||
@@ -17,7 +17,7 @@ import { RequireLoggedIn } from "../../middleware/require-logged-in";
|
||||
|
||||
const logger = CreateLogCtx("auth.ts");
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
const LAZY_EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/u;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user