port museca

This commit is contained in:
zkldi
2021-05-10 04:44:18 +01:00
parent 5a5cdaa475
commit d933b6d68b
2 changed files with 78 additions and 0 deletions
@@ -0,0 +1,52 @@
import { ChartDocument } from "kamaitachi-common";
import db from "../../src/db/db";
import CreateLogCtx from "../../src/logger";
import MigrateRecords from "./migrate";
import { gameOrders } from "kamaitachi-common/js/config";
const logger = CreateLogCtx("charts-museca.ts");
async function ConvertFn(c: any): Promise<ChartDocument<"museca:Single">> {
let song = await db.songs.museca.findOne({
id: c.id,
});
if (!song) {
logger.severe(`Cannot find song with ID ${c.id}?`);
throw new Error(`Cannot find song with ID ${c.id}?`);
}
const newChartDoc: ChartDocument<"museca:Single"> = {
rgcID: null,
chartID: c.chartID,
difficulty: c.difficulty,
songID: c.id,
playtype: c.playtype,
levelNum: c.levelNum,
level: c.level.toString(),
flags: {
"IN BASE GAME": true,
OMNIMIX: true, // false, needs to be overrode for 3 or so charts
},
data: {},
isPrimary: true,
versions: [], // sentinel
};
let idx = gameOrders.museca.indexOf(song.firstVersion!);
if (idx === -1) {
logger.warn(`Invalid firstAppearance of ${song.firstVersion!}, running anyway.`);
newChartDoc.versions = [song.firstVersion!];
} else {
newChartDoc.versions = gameOrders.museca.slice(idx);
}
return newChartDoc;
}
(async () => {
await MigrateRecords(db.charts.museca, "charts-museca", ConvertFn);
process.exit(0);
})();
@@ -0,0 +1,26 @@
import { SongDocument } from "kamaitachi-common";
import db from "../../src/db/db";
import MigrateRecords from "./migrate";
function ConvertFn(c: any): SongDocument<"museca"> {
const newSongDoc: SongDocument<"museca"> = {
title: c.title,
artist: c.artist,
id: c.id,
firstVersion: c.firstAppearance,
"alt-titles": [],
"search-titles": [],
data: {
titleJP: c.title_jp,
artistJP: c.artist_jp,
},
};
return newSongDoc;
}
(async () => {
await MigrateRecords(db.songs.museca, "songs-museca", ConvertFn);
process.exit(0);
})();