Update categories for EDB ID script
This commit is contained in:
parent
37129d3833
commit
644a7e1d92
2 changed files with 18 additions and 11 deletions
|
|
@ -33,18 +33,21 @@ function insertInfoboxEDBID (pageContent, edbID) {
|
||||||
|
|
||||||
const mw = await getMediawikiClient();
|
const mw = await getMediawikiClient();
|
||||||
|
|
||||||
// Get pages in the "Missing EDB ID" category from the main article namespace
|
const categoryTypes = {
|
||||||
const [itemPagesWithoutEDBIDs, questPagesWithoutEDBIDs] = await Promise.all([
|
'Category:Items with no EDB ID specified': 'item',
|
||||||
mw.listCategoryPages('Category:Missing EDB ID', [0], +process.env.LIMIT || 500),
|
'Category:Minions with no EDB ID specified': 'item',
|
||||||
mw.listCategoryPages('Category:Missing quest EDB ID', [0], +process.env.LIMIT || 500),
|
'Category:Triple Triad cards with no EDB ID specified': 'item',
|
||||||
]);
|
'Category:Quests with no EDB ID specified': 'quest',
|
||||||
console.log('Processing', itemPagesWithoutEDBIDs.length, 'item pages from [[Category:Missing EDB ID]]\n');
|
};
|
||||||
console.log('Processing', questPagesWithoutEDBIDs.length, 'item pages from [[Category:Missing quest EDB ID]]\n');
|
|
||||||
|
|
||||||
for (const {title, type} of [
|
const pages = (await Promise.all(Object.entries(categoryTypes).map(async ([category, type]) => {
|
||||||
...itemPagesWithoutEDBIDs.map(({title}) => ({title, type: 'item'})),
|
const pages = await mw.listCategoryPages(category, [0], +process.env.LIMIT || 500);
|
||||||
...questPagesWithoutEDBIDs.map(({title}) => ({title, type: 'quest'})),
|
return pages.map(({title}) => ({title, type}));
|
||||||
]) {
|
}))).flat();
|
||||||
|
|
||||||
|
console.log('Processing', pages.length, 'items\n');
|
||||||
|
|
||||||
|
for (const {title, type} of pages) {
|
||||||
// this runs serially with an artificial delay between requests to decrease
|
// this runs serially with an artificial delay between requests to decrease
|
||||||
// the chance of sqenix sending ninjas to my house
|
// the chance of sqenix sending ninjas to my house
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env -S node --env-file-if-exists=.env
|
#!/usr/bin/env -S node --env-file-if-exists=.env
|
||||||
|
|
||||||
|
console.log(process.env);
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
import {findItemGTID} from '../lib/api/xivapi.js';
|
import {findItemGTID} from '../lib/api/xivapi.js';
|
||||||
import {getMediawikiClient} from '../lib/config.js';
|
import {getMediawikiClient} from '../lib/config.js';
|
||||||
import {diff} from '../lib/util/diff.js';
|
import {diff} from '../lib/util/diff.js';
|
||||||
|
|
@ -33,6 +36,7 @@ function insertInfoboxGTBID (pageContent, gtID) {
|
||||||
|
|
||||||
const mw = await getMediawikiClient();
|
const mw = await getMediawikiClient();
|
||||||
|
|
||||||
|
// TODO: update this to work with the new maintenance category hierarchy
|
||||||
// Get pages in the "Missing internal ID" category from the main article namespace
|
// Get pages in the "Missing internal ID" category from the main article namespace
|
||||||
const itemPagesWithoutGTIDs = await mw.listCategoryPages('Category:Missing internal ID', [0], +process.env.LIMIT || 500);
|
const itemPagesWithoutGTIDs = await mw.listCategoryPages('Category:Missing internal ID', [0], +process.env.LIMIT || 500);
|
||||||
console.log('Processing', itemPagesWithoutGTIDs.length, 'item pages from [[Category:Missing internal ID]]\n');
|
console.log('Processing', itemPagesWithoutGTIDs.length, 'item pages from [[Category:Missing internal ID]]\n');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue