mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 13:58:05 +03:00
kt db migration groundwrok
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
This folder is for porting documents from the old KamaitachiDB to the newer formats.
|
||||
|
||||
The scripts here should NOT be ran unless you know *exactly* what the hell you're doing.
|
||||
|
||||
And, even then - basically only I know, so. Please be careful.
|
||||
@@ -0,0 +1,3 @@
|
||||
import monk from "monk";
|
||||
|
||||
export const oldKTDB = monk("127.0.0.1:27017/kamaitachidb");
|
||||
@@ -0,0 +1,56 @@
|
||||
import { PrivateUserDocument, ScoreDocument } from "kamaitachi-common";
|
||||
import { grades } from "kamaitachi-common/js/config";
|
||||
import db from "../../db/db";
|
||||
import MigrateRecords from "./migrate";
|
||||
|
||||
// HERE. WE. GO!
|
||||
|
||||
function ConvertFn(c: any): ScoreDocument {
|
||||
let base: Partial<ScoreDocument> = {
|
||||
userID: c.userID,
|
||||
songID: c.songID,
|
||||
playtype: c.scoreData.playtype,
|
||||
difficulty: c.scoreData.difficulty,
|
||||
chartID: c.chartID,
|
||||
game: c.game,
|
||||
timeAdded: c.timeAdded,
|
||||
timeAchieved: c.timeAchieved,
|
||||
isScorePB: c.isScorePB,
|
||||
isLampPB: c.isLampPB,
|
||||
comment: c.comment ?? null,
|
||||
highlight: c.highlight ?? false,
|
||||
service: c.service,
|
||||
importType: null,
|
||||
calculatedData: c.calculatedData,
|
||||
scoreData: {
|
||||
esd: c.scoreData.esd ?? null,
|
||||
grade: c.scoreData.grade,
|
||||
// @ts-expect-error shut
|
||||
gradeIndex: grades[c.game].indexOf(c.scoreData.grade),
|
||||
lamp: c.scoreData.lamp,
|
||||
// @ts-expect-error shut
|
||||
lampIndex: lamps[c.game].indexOf(c.scoreData.lamp),
|
||||
percent: c.scoreData.percent,
|
||||
score: c.scoreData.score,
|
||||
hitData: c.scoreData.hitData,
|
||||
hitMeta: c.scoreData.hitMeta,
|
||||
},
|
||||
scoreMeta: {},
|
||||
};
|
||||
|
||||
switch (base.game) {
|
||||
case "bms":
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await MigrateRecords(db.users, "users", ConvertFn);
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
import { PrivateUserDocument } from "kamaitachi-common";
|
||||
import db from "../../db/db";
|
||||
import MigrateRecords from "./migrate";
|
||||
|
||||
function ConvertFn(c: any): PrivateUserDocument {
|
||||
const newUserDoc: PrivateUserDocument = {
|
||||
username: c.username,
|
||||
usernameLowercase: c.username.toLowerCase(),
|
||||
about: c.about,
|
||||
clan: c.clan,
|
||||
customBanner: c.custombanner,
|
||||
customPfp: c.custompfp,
|
||||
email: c.email,
|
||||
friends: c.friends,
|
||||
id: c.id,
|
||||
lastSeen: c.lastSeen,
|
||||
password: c.password,
|
||||
permissions: {},
|
||||
settings: {
|
||||
invisible: !!c.settings.invisible,
|
||||
nsfwSplashes: !!c.settings.nsfwsplashes,
|
||||
},
|
||||
socialMedia: {
|
||||
discord: c.socialmedia.discord || null,
|
||||
twitter: c.socialmedia.twitter || null,
|
||||
youtube: c.socialmedia.youtube || null,
|
||||
twitch: c.socialmedia.twitch || null,
|
||||
github: c.socialmedia.github || null,
|
||||
steam: c.socialmedia.steam || null,
|
||||
},
|
||||
};
|
||||
|
||||
return newUserDoc;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await MigrateRecords(db.users, "users", ConvertFn);
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
Reference in New Issue
Block a user