Fix logic error preventing changed wiki articles from being checked
This commit is contained in:
parent
e11d613694
commit
8bf5505ffa
7 changed files with 330 additions and 496 deletions
|
@ -14,6 +14,7 @@ interface Cli {
|
|||
irregularPathUntagged?: boolean,
|
||||
skipUntil?: string,
|
||||
recent?: boolean,
|
||||
missing?: boolean,
|
||||
limit?: number,
|
||||
steam?: boolean,
|
||||
}
|
||||
|
@ -27,6 +28,7 @@ async function main() {
|
|||
"all",
|
||||
"irregularPathUntagged",
|
||||
"steam",
|
||||
"missing",
|
||||
],
|
||||
string: [
|
||||
"skipUntil",
|
||||
|
@ -54,7 +56,7 @@ async function main() {
|
|||
if (args.wiki) {
|
||||
if (args.recent) {
|
||||
await wikiCache.flagRecentChanges(wikiMetaCache);
|
||||
} else {
|
||||
} else if (args.missing) {
|
||||
await wikiCache.addNewGames();
|
||||
}
|
||||
|
||||
|
@ -62,6 +64,7 @@ async function main() {
|
|||
args.skipUntil,
|
||||
args.limit ?? DEFAULT_GAME_LIMIT,
|
||||
args.all ?? false,
|
||||
args._ ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -76,7 +79,7 @@ async function main() {
|
|||
if (args.manifest) {
|
||||
await manifest.updateGames(
|
||||
wikiCache.data,
|
||||
args._,
|
||||
args._ ?? [],
|
||||
steamCache,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -173,13 +173,13 @@ export class ManifestFile extends YamlFile<Manifest> {
|
|||
|
||||
async updateGames(
|
||||
wikiCache: WikiGameCache,
|
||||
games: Array<string> | undefined,
|
||||
games: Array<string>,
|
||||
steamCache: SteamGameCacheFile,
|
||||
): Promise<void> {
|
||||
this.data = {};
|
||||
|
||||
for (const [title, info] of Object.entries(wikiCache).sort()) {
|
||||
if (games !== undefined && games?.length > 0 && !games.includes(title)) {
|
||||
if (games?.length > 0 && !games.includes(title)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
15
src/wiki.ts
15
src/wiki.ts
|
@ -78,7 +78,7 @@ export class WikiGameCacheFile extends YamlFile<WikiGameCache> {
|
|||
};
|
||||
}
|
||||
|
||||
async refresh(skipUntil: string | undefined, limit: number, all: boolean | undefined): Promise<void> {
|
||||
async refresh(skipUntil: string | undefined, limit: number, all: boolean, games: Array<string>): Promise<void> {
|
||||
let i = 0;
|
||||
let foundSkipUntil = false;
|
||||
const client = makeApiClient();
|
||||
|
@ -90,7 +90,9 @@ export class WikiGameCacheFile extends YamlFile<WikiGameCache> {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (!all && (this.data[pageTitle].revId !== null || !this.data[pageTitle].recentlyChanged)) {
|
||||
if (games.length > 0 && !games.includes(pageTitle)) {
|
||||
continue;
|
||||
} else if (!all && this.data[pageTitle].revId !== null && !this.data[pageTitle].recentlyChanged) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -525,7 +527,7 @@ export async function getRecentChanges(newest: Date, oldest: Date): Promise<Rece
|
|||
/**
|
||||
* https://www.pcgamingwiki.com/wiki/Template:Game_data
|
||||
*/
|
||||
export async function getGame(pageTitle: string, cache: WikiGameCache, client: Wikiapi = null): Promise<[string, Game]> {
|
||||
export async function getGame(pageTitle: string, cache: WikiGameCache, client: Wikiapi = null): Promise<string> {
|
||||
console.log(pageTitle);
|
||||
const wiki = client === null ? makeApiClient() : client;
|
||||
let page = await wiki.page(pageTitle, { rvprop: "ids|content" });
|
||||
|
@ -563,17 +565,12 @@ export async function getGame(pageTitle: string, cache: WikiGameCache, client: W
|
|||
}
|
||||
}
|
||||
|
||||
const game: Game = {
|
||||
files: {},
|
||||
registry: {},
|
||||
};
|
||||
delete cache[pageTitle].templates;
|
||||
page.parse().each("template", template => {
|
||||
const templateName = template.name.toLowerCase();
|
||||
if (templateName === "Infobox game") {
|
||||
const steamId = Number(template.parameters["steam appid"]);
|
||||
if (!isNaN(steamId) && steamId > 0) {
|
||||
game.steam = { id: steamId };
|
||||
cache[pageTitle].steam = steamId;
|
||||
}
|
||||
} else if (templateName === "game data/saves" || templateName === "game data/config") {
|
||||
|
@ -589,7 +586,7 @@ export async function getGame(pageTitle: string, cache: WikiGameCache, client: W
|
|||
|
||||
cache[pageTitle].revId = page.revisions?.[0]?.revid ?? 0;
|
||||
delete cache[pageTitle].recentlyChanged;
|
||||
return [pageTitle, game];
|
||||
return pageTitle;
|
||||
}
|
||||
|
||||
function flattenParameter(nodes: Array<WikiNode>): [string, boolean] {
|
||||
|
|
Reference in a new issue