Skip to content

Commit

Permalink
db-tabulator: handle metadata update when pages are moved or deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Jan 22, 2024
1 parent 6530448 commit f05936a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions db-tabulator/eventstream-metadata-maintainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {HybridMetadataStore} from "./HybridMetadataStore";
import {NoMetadataStore} from "./NoMetadataStore";
import {createLocalSSHTunnel, setDifference} from "../utils";
import {ENWIKI_DB_HOST} from "../db";
import {RecentChangeStreamEvent} from "../eventstream-router/RecentChangeStreamEvent";

/**
* If there are a large number of reports, we want to identify which reports need updating without reading in the pages.
Expand Down Expand Up @@ -47,13 +48,14 @@ export default class DbTabulatorMetadata extends Route {
await this.refreshExistingMetadata();
}

filter(data): boolean {
filter(data: RecentChangeStreamEvent): boolean {
return data.wiki === 'enwiki' &&
((data.type === 'categorize' && data.title === 'Category:' + SUBSCRIPTIONS_CATEGORY) ||
(data.type === 'edit' && this.subscriptions.has(data.title) && data.user !== BOT_NAME));
((data.type === 'edit' || (data.type === 'log' && (data.log_type === 'move' || data.log_type === 'delete')))
&& this.subscriptions.has(data.title) && data.user !== BOT_NAME));
}

async worker(data) {
async worker(data: RecentChangeStreamEvent) {
if (data.type === 'categorize') {
let page = pageFromCategoryEvent(data);
if (page.added) {
Expand All @@ -62,7 +64,10 @@ export default class DbTabulatorMetadata extends Route {
this.subscriptions.delete(page.title);
}
this.updateMetadata(page.title);
} else {
} else if (data.log_type === 'move') {
this.updateMetadata(data.title);
this.updateMetadata(data.log_params.target);
} else { // edits, deletions
this.updateMetadata(data.title);
}
}
Expand Down

0 comments on commit f05936a

Please sign in to comment.