Add script for finding duplicate entries

This commit is contained in:
mtkennerly 2022-10-06 16:50:00 +08:00
parent 891ca12890
commit 6fc21111aa
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 32 additions and 0 deletions

View file

@ -10,6 +10,7 @@ interface Cli {
wiki?: boolean,
manifest?: boolean,
stats?: boolean,
duplicates?: boolean,
all?: boolean,
irregularPathUntagged?: boolean,
skipUntil?: string,
@ -52,6 +53,33 @@ async function main() {
process.exit(0);
}
if (args.duplicates) {
const data: {[key: string]: Array<{ name: string; pageId: number }>} = {};
for (const [name, info] of Object.entries(manifest.data)) {
const key = JSON.stringify(info);
let safe = false;
for (const file of Object.keys(info.files ?? {})) {
if (file.includes("<game>") || file.includes("<base>")) {
safe = true;
}
}
if (safe) {
continue;
}
if (!(key in data)) {
data[key] = [];
}
data[key].push({ name, pageId: wikiCache.data[name]?.pageId ?? 0 });
}
for (const games of Object.values(data)) {
if (games.length > 1) {
const lines = games.map(({ name, pageId }) => `[${pageId}] ${name}`);
console.log(`\nSame manifest entry:\n - ${lines.join("\n - ")}`);
}
}
process.exit(0);
}
try {
if (args.wiki) {
if (args.recent) {