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
+14 -14
View File
@@ -3,19 +3,19 @@
import db from "../../src/db/db";
db.charts.iidx
.find({})
.each(async (c, { pause, resume }) => {
pause();
.find({})
.each(async (c, { pause, resume }) => {
pause();
await db.charts.iidx.update(
{ _id: c._id },
{
$set: {
"flags.2dxtra": false,
},
}
);
await db.charts.iidx.update(
{ _id: c._id },
{
$set: {
"flags.2dxtra": false,
},
}
);
resume();
})
.then(() => console.log("done"));
resume();
})
.then(() => console.log("done"));
+9 -9
View File
@@ -7,18 +7,18 @@ import CreateLogCtx from "../../src/common/logger";
const logger = CreateLogCtx(__filename);
let data = JSON.parse(fs.readFileSync(path.join(__dirname, "./hcnverdata.json"), "utf-8"));
const data = JSON.parse(fs.readFileSync(path.join(__dirname, "./hcnverdata.json"), "utf-8"));
for (const d of data) {
let r = p(d, PRUDENCE_CHART_SCHEMAS.iidx);
if (r) {
logger.error(r.userVal);
logger.error(r);
throw r;
}
const r = p(d, PRUDENCE_CHART_SCHEMAS.iidx);
if (r) {
logger.error(r.userVal);
logger.error(r);
throw r;
}
}
db.charts.iidx.insert(data).then(() => {
logger.info("Done.");
process.exit(0);
logger.info("Done.");
process.exit(0);
});
+13 -13
View File
@@ -1,18 +1,18 @@
import db from "../../src/db/db";
(async () => {
let charts = await db.charts.chunithm.find({});
const charts = await db.charts.chunithm.find({});
for (const c of charts) {
await db.charts.chunithm.update(
{
_id: c._id,
},
{
$set: {
"data.inGameID": c.songID,
},
}
);
}
for (const c of charts) {
await db.charts.chunithm.update(
{
_id: c._id,
},
{
$set: {
"data.inGameID": c.songID,
},
}
);
}
})();
@@ -2,27 +2,27 @@ import db from "../../../src/db/db";
import { ChartDocument } from "tachi-common";
db.charts.iidx
.find({})
// @ts-expect-error it exists
.each(async (c: ChartDocument<"iidx:SP" | "iidx:DP">, { pause, resume }: any) => {
pause();
.find({})
// @ts-expect-error it exists
.each(async (c: ChartDocument<"iidx:SP" | "iidx:DP">, { pause, resume }: any) => {
pause();
const song = (await db.songs.iidx.findOne({ id: c.songID }))!;
const song = (await db.songs.iidx.findOne({ id: c.songID }))!;
let versions = [];
let versions = [];
if (song.firstVersion === "27") {
versions = ["27", "28", "27-omni", "28-omni"];
} else if (song.firstVersion === "28") {
versions = ["28", "28-omni"];
} else if (song.firstVersion === "inf") {
versions = ["inf"];
} else {
versions = ["26", "27", "28", "26-omni", "27-omni", "28-omni"];
}
if (song.firstVersion === "27") {
versions = ["27", "28", "27-omni", "28-omni"];
} else if (song.firstVersion === "28") {
versions = ["28", "28-omni"];
} else if (song.firstVersion === "inf") {
versions = ["inf"];
} else {
versions = ["26", "27", "28", "26-omni", "27-omni", "28-omni"];
}
await db.charts.iidx.update({ _id: c._id }, { $set: { versions } });
await db.charts.iidx.update({ _id: c._id }, { $set: { versions } });
resume();
})
.then(() => console.log("done"));
resume();
})
.then(() => console.log("done"));
@@ -4,17 +4,17 @@ import db from "../../../src/db/db";
const logger = CreateLogCtx(__filename);
(async () => {
const charts = await db.charts.iidx.find({ versions: { $size: 0 } });
const charts = await db.charts.iidx.find({ versions: { $size: 0 } });
for (const chart of charts) {
// eslint-disable-next-line no-await-in-loop
const song = await db.songs.iidx.findOne({ id: chart.songID });
for (const chart of charts) {
// eslint-disable-next-line no-await-in-loop
const song = await db.songs.iidx.findOne({ id: chart.songID });
if (!song) {
logger.error(`cannot find parent song ${chart.songID}`);
continue;
}
if (!song) {
logger.error(`cannot find parent song ${chart.songID}`);
continue;
}
logger.info(`${song.title} ${chart.playtype} ${chart.difficulty}`);
}
logger.info(`${song.title} ${chart.playtype} ${chart.difficulty}`);
}
})();
@@ -7,90 +7,90 @@ import { FindSongOnTitleInsensitive } from "../../../src/common/database-lookup/
const logger = CreateLogCtx(__filename);
const comicallyLargeJSONData = JSON.parse(
fs.readFileSync(path.join(__dirname, "./versions.json"), "utf-8")
fs.readFileSync(path.join(__dirname, "./versions.json"), "utf-8")
);
const DIFF_MAP = {
A: "ANOTHER",
H: "HYPER",
N: "NORMAL",
B: "BEGINNER",
X: "LEGGENDARIA",
A: "ANOTHER",
H: "HYPER",
N: "NORMAL",
B: "BEGINNER",
X: "LEGGENDARIA",
} as any;
function ConvertVersion(c: string) {
if (c.startsWith("AC")) {
return c.split("AC")[1];
} else if (c.startsWith("OM")) {
return `${c.split("OM")[1]}-omni`;
} else if (c.startsWith("CS")) {
return `${c.split("CS")[1]}-cs`;
} else if (c === "INF") {
return "inf";
} else if (c === "BMUS") {
return "bmus";
} else {
logger.error(`Invalid Chart Version ${c}.`);
throw new Error("Invalid Chart Version");
}
if (c.startsWith("AC")) {
return c.split("AC")[1];
} else if (c.startsWith("OM")) {
return `${c.split("OM")[1]}-omni`;
} else if (c.startsWith("CS")) {
return `${c.split("CS")[1]}-cs`;
} else if (c === "INF") {
return "inf";
} else if (c === "BMUS") {
return "bmus";
} else {
logger.error(`Invalid Chart Version ${c}.`);
throw new Error("Invalid Chart Version");
}
}
(async () => {
for (const data of comicallyLargeJSONData) {
const song = await FindSongOnTitleInsensitive("iidx", data["MUSIC NAME"]);
for (const data of comicallyLargeJSONData) {
const song = await FindSongOnTitleInsensitive("iidx", data["MUSIC NAME"]);
if (!song) {
logger.error(`Can't find song with title ${data["MUSIC NAME"]}.`);
continue;
}
if (!song) {
logger.error(`Can't find song with title ${data["MUSIC NAME"]}.`);
continue;
}
const playtype = data.STYLE === "S" ? "SP" : "DP";
const playtype = data.STYLE === "S" ? "SP" : "DP";
const difficulty = DIFF_MAP[data.DIFF];
const difficulty = DIFF_MAP[data.DIFF];
const relevantVersions = [
"OM27",
"OM26",
"AC27",
"AC26",
"INF",
"CS16",
"CS15",
"CS14",
"CS13",
"CS12",
"CS11",
"CS10",
"CS9",
"CS8",
"CS7",
"BMUS",
"CS6",
"CS5",
"CS4",
"CS3",
]
.filter((e) => data[e] === "1")
.map(ConvertVersion);
const relevantVersions = [
"OM27",
"OM26",
"AC27",
"AC26",
"INF",
"CS16",
"CS15",
"CS14",
"CS13",
"CS12",
"CS11",
"CS10",
"CS9",
"CS8",
"CS7",
"BMUS",
"CS6",
"CS5",
"CS4",
"CS3",
]
.filter((e) => data[e] === "1")
.map(ConvertVersion);
if (!relevantVersions.includes("27-omni") && !relevantVersions.includes("inf")) {
logger.warn(`Song ${song.title} (${playtype} ${difficulty}) has no relevant versions.`);
continue;
}
if (!relevantVersions.includes("27-omni") && !relevantVersions.includes("inf")) {
logger.warn(`Song ${song.title} (${playtype} ${difficulty}) has no relevant versions.`);
continue;
}
// logger.info(relevantVersions);q
// logger.info(relevantVersions);q
const chart = await db.charts.iidx.findOne({ songID: song.id, difficulty, playtype });
const chart = await db.charts.iidx.findOne({ songID: song.id, difficulty, playtype });
if (!chart) {
logger.error(`Can't find chart ${song.title} (${playtype} ${difficulty})`);
continue;
}
if (!chart) {
logger.error(`Can't find chart ${song.title} (${playtype} ${difficulty})`);
continue;
}
await db.charts.iidx.update({ _id: chart._id }, { $set: { versions: relevantVersions } });
}
await db.charts.iidx.update({ _id: chart._id }, { $set: { versions: relevantVersions } });
}
logger.info("done");
logger.info("done");
process.exit(0);
process.exit(0);
})();
@@ -2,27 +2,27 @@ import db from "../../src/db/db";
import { FolderDocument } from "tachi-common";
(async () => {
const folders = (await db.folders.find({})) as any[];
const folders = (await db.folders.find({})) as any[];
for (const fl of folders) {
const f: FolderDocument = {
folderID: fl.folderID,
game: fl.game,
playtype: fl.playtype,
table: fl.table,
tableIndex: fl.tableIndex,
title: fl.title,
type: fl.query.collection === "charts" ? "charts" : "songs",
data: fl.query.body,
};
for (const fl of folders) {
const f: FolderDocument = {
folderID: fl.folderID,
game: fl.game,
playtype: fl.playtype,
table: fl.table,
tableIndex: fl.tableIndex,
title: fl.title,
type: fl.query.collection === "charts" ? "charts" : "songs",
data: fl.query.body,
};
await db.folders.update(
{
_id: fl._id,
},
{ $set: f }
);
}
await db.folders.update(
{
_id: fl._id,
},
{ $set: f }
);
}
console.log("done");
console.log("done");
})();
+18 -18
View File
@@ -1,24 +1,24 @@
import db from "../../src/db/db";
(async () => {
db.folders
.find({})
// @ts-expect-error ??? monk
.each(async (c, { pause, resume }) => {
pause();
db.folders
.find({})
// @ts-expect-error ??? monk
.each(async (c, { pause, resume }) => {
pause();
await db.folders.update(
{
_id: c._id,
},
{
$set: {
tableIndex: Number(c.tableIndex),
},
}
);
await db.folders.update(
{
_id: c._id,
},
{
$set: {
tableIndex: Number(c.tableIndex),
},
}
);
resume();
})
.then(() => console.log("done"));
resume();
})
.then(() => console.log("done"));
})();
+4 -4
View File
@@ -8,14 +8,14 @@ const logger = CreateLogCtx(__filename);
let parsedXML;
const fileData = fs.readFileSync(
path.join(__dirname, "../../src/test-utils/test-data/s3/valid.xml"),
"utf-8"
path.join(__dirname, "../../src/test-utils/test-data/s3/valid.xml"),
"utf-8"
);
try {
parsedXML = parser.parse(fileData);
parsedXML = parser.parse(fileData);
} catch (err) {
logger.error(err);
logger.error(err);
}
fs.writeFileSync(path.join(__dirname, "s3data.json"), JSON.stringify(parsedXML, null, 4));
+3 -3
View File
@@ -3,7 +3,7 @@ import db from "../../db/db";
import path from "path";
(async () => {
let data = await db.scores.find({ game: "iidx", playtype: "SP" }, { limit: 1000 });
fs.writeFileSync(path.join(__dirname, "data.json"), JSON.stringify(data));
process.exit(0);
const data = await db.scores.find({ game: "iidx", playtype: "SP" }, { limit: 1000 });
fs.writeFileSync(path.join(__dirname, "data.json"), JSON.stringify(data));
process.exit(0);
})();