i accidentally the eslint

This commit is contained in:
zkldi
2021-08-10 04:28:43 +01:00
parent d962de5735
commit a57245f373
45 changed files with 1225 additions and 1240 deletions
@@ -4,7 +4,7 @@ import path from "path";
import db from "../../../src/external/mongo/db";
(async () => {
const data = JSON.parse(fs.readFileSync(path.join(__dirname, "courses.json"), "utf-8"));
const data = JSON.parse(fs.readFileSync(path.join(__dirname, "courses.json"), "utf-8"));
await db["bms-course-lookup"].insert(data);
await db["bms-course-lookup"].insert(data);
})();
@@ -8,13 +8,13 @@ const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "./charts.json"),
const songs = JSON.parse(fs.readFileSync(path.join(__dirname, "./songs.json"), "utf-8"));
(async () => {
logger.info("starting chart import.");
await db.charts.bms.remove({});
await db.charts.bms.insert(charts);
logger.info("imported charts.");
logger.info("starting chart import.");
await db.charts.bms.remove({});
await db.charts.bms.insert(charts);
logger.info("imported charts.");
await db.songs.bms.remove({});
await db.songs.bms.insert(songs);
await db.songs.bms.remove({});
await db.songs.bms.insert(songs);
logger.info("done.");
logger.info("done.");
})();
+66 -66
View File
@@ -18,83 +18,83 @@ program.parse(process.argv);
const options = program.opts();
const dataset = JSON.parse(
fs.readFileSync(path.join(__dirname, "./out.json"), "utf-8")
fs.readFileSync(path.join(__dirname, "./out.json"), "utf-8")
) as MDBJson[];
const logger = CreateLogCtx(__filename);
(async () => {
for (const data of dataset) {
for (const d in data.difficulties) {
const diff = d as keyof typeof data.difficulties;
for (const data of dataset) {
for (const d in data.difficulties) {
const diff = d as keyof typeof data.difficulties;
if (data.difficulties[diff] === 0) {
logger.verbose(`Skipping chart ${data.title} ${diff}`);
continue;
}
if (data.difficulties[diff] === 0) {
logger.verbose(`Skipping chart ${data.title} ${diff}`);
continue;
}
const spl = diff.split("-");
const chart = (await db.charts.iidx.findOne({
"data.inGameID": data.songID,
playtype: spl[0] as Playtypes["iidx"],
difficulty: spl[1] as Difficulties["iidx:SP" | "iidx:DP"],
isPrimary: true,
})) as ChartDocument<"iidx:SP" | "iidx:DP">;
const spl = diff.split("-");
const chart = (await db.charts.iidx.findOne({
"data.inGameID": data.songID,
playtype: spl[0] as Playtypes["iidx"],
difficulty: spl[1] as Difficulties["iidx:SP" | "iidx:DP"],
isPrimary: true,
})) as ChartDocument<"iidx:SP" | "iidx:DP">;
if (!chart) {
logger.warn(`No chart exists for ${data.title} (${diff}).`);
continue;
}
if (!chart) {
logger.warn(`No chart exists for ${data.title} (${diff}).`);
continue;
}
if (chart.levelNum !== data.difficulties[diff]) {
logger.warn(
`Level Mismatch with ${data.title} (${diff}) [${chart.levelNum} -> ${data.difficulties[diff]}]`
);
if (chart.levelNum !== data.difficulties[diff]) {
logger.warn(
`Level Mismatch with ${data.title} (${diff}) [${chart.levelNum} -> ${data.difficulties[diff]}]`
);
if (options.sync) {
await db.charts.iidx.update(
{
_id: chart._id,
},
{
$set: {
levelNum: data.difficulties[diff],
level: data.difficulties[diff].toString(),
},
}
);
}
}
if (options.sync) {
await db.charts.iidx.update(
{
_id: chart._id,
},
{
$set: {
levelNum: data.difficulties[diff],
level: data.difficulties[diff].toString(),
},
}
);
}
}
if (chart.data.notecount !== data.notecounts[diff]) {
if (
data.notecounts[diff] === undefined ||
Math.abs(chart.data.notecount - data.notecounts[diff]!) > 2
) {
logger.error(
`Significant Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}] - skipping.`
);
// continue;
}
if (chart.data.notecount !== data.notecounts[diff]) {
if (
data.notecounts[diff] === undefined ||
Math.abs(chart.data.notecount - data.notecounts[diff]!) > 2
) {
logger.error(
`Significant Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}] - skipping.`
);
// continue;
}
logger.warn(
`Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}]`
);
logger.warn(
`Notecount Mismatch with ${data.title} (${diff}) [${chart.data.notecount} -> ${data.notecounts[diff]}]`
);
if (options.sync) {
await db.charts.iidx.update(
{
_id: chart._id,
},
{
$set: {
"data.notecount": data.notecounts[diff],
},
}
);
}
}
}
}
logger.info("done");
if (options.sync) {
await db.charts.iidx.update(
{
_id: chart._id,
},
{
$set: {
"data.notecount": data.notecounts[diff],
},
}
);
}
}
}
}
logger.info("done");
})();
+8 -8
View File
@@ -1,12 +1,12 @@
export interface MDBJson {
title: string;
artist: string;
marquee: string;
folder: number;
genre: string;
difficulties: Record<DiffNames, number>;
notecounts: Partial<Record<DiffNames, number>>;
songID: number;
title: string;
artist: string;
marquee: string;
folder: number;
genre: string;
difficulties: Record<DiffNames, number>;
notecounts: Partial<Record<DiffNames, number>>;
songID: number;
}
type DiffNames = `${"SP" | "DP"}-${"BEGINNER" | "NORMAL" | "HYPER" | "ANOTHER" | "LEGGENDARIA"}`;
+15 -15
View File
@@ -7,25 +7,25 @@ const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "charts.json"), "
const map: Map<string, any> = new Map();
for (const chart of charts) {
const id = `${chart.songID}-${chart.difficulty}`;
const doc = map.get(id);
const id = `${chart.songID}-${chart.difficulty}`;
const doc = map.get(id);
if (doc) {
if (Array.isArray(doc.data.hashSHA1)) {
doc.data.hashSHA1.push(chart.data.hashSHA1);
} else {
doc.data.hashSHA1 = [doc.data.hashSHA1, chart.data.hashSHA1];
}
if (doc) {
if (Array.isArray(doc.data.hashSHA1)) {
doc.data.hashSHA1.push(chart.data.hashSHA1);
} else {
doc.data.hashSHA1 = [doc.data.hashSHA1, chart.data.hashSHA1];
}
// insane hack
chart.erasethis = true;
} else {
map.set(id, chart);
}
// insane hack
chart.erasethis = true;
} else {
map.set(id, chart);
}
}
// works because byref
fs.writeFileSync(
path.join(__dirname, "deduped-charts.json"),
JSON.stringify(charts.filter((e: any) => e.erasethis !== true))
path.join(__dirname, "deduped-charts.json"),
JSON.stringify(charts.filter((e: any) => e.erasethis !== true))
);
+4 -4
View File
@@ -6,8 +6,8 @@ const songs = JSON.parse(fs.readFileSync(path.join(__dirname, "songs.json"), "ut
const charts = JSON.parse(fs.readFileSync(path.join(__dirname, "deduped-charts.json"), "utf-8"));
(async () => {
await db.songs.usc.remove({});
await db.charts.usc.remove({});
await db.songs.usc.insert(songs);
await db.charts.usc.insert(charts);
await db.songs.usc.remove({});
await db.charts.usc.remove({});
await db.songs.usc.insert(songs);
await db.charts.usc.insert(charts);
})();