Skip to content

Commit

Permalink
feat: periodically delete used MediumInWaits
Browse files Browse the repository at this point in the history
  • Loading branch information
mytlogos committed Sep 5, 2022
1 parent 654935e commit abf42a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/database/contexts/mediumInWaitContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,11 @@ export class MediumInWaitContext extends SubContext {
);
multiSingle(results, (result) => storeModifications("medium_in_wait", "insert", result));
}

public async deleteUsedMediumInWait() {
const result = await this.dmlQuery(
"delete from medium_in_wait where (title, medium, link) in (select title, medium, link from medium_toc);",
);
storeModifications("medium_in_wait", "delete", result);
}
}
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ export enum ScrapeName {
queueTocs = "queueTocs",
remapMediaParts = "remapMediaParts",
queueExternalUser = "queueExternalUser",
removeUsedMediaInWaits = "removeUsedMediaInWaits",
}

export enum JobState {
Expand Down
6 changes: 6 additions & 0 deletions packages/scraper/src/scheduler/scrapeJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { list } from "../jobs/oneTimeUser";
import { queueExternalUser } from "../jobs/queueExternalUser";
import { queueTocsJob } from "../jobs/queueTocs";
import { remapMediaParts } from "../jobs/remapMediumParts";
import { removeUsedMediaInWaits } from "../jobs/removeUsedMediaInWaits";
import { searchForTocJob } from "../jobs/searchForToc";
import { toc, oneTimeToc } from "../jobs/toc";

Expand All @@ -21,6 +22,11 @@ export class ScrapeJob {
public static readonly checkTocs = new ScrapeJob(ScrapeName.checkTocs, checkTocsJob);
public static readonly queueTocs = new ScrapeJob(ScrapeName.queueTocs, queueTocsJob);
public static readonly remapMediaParts = new ScrapeJob(ScrapeName.remapMediaParts, remapMediaParts);
public static readonly removeUsedMediaInWaits = new ScrapeJob(
ScrapeName.removeUsedMediaInWaits,
removeUsedMediaInWaits,
);

public static readonly queueExternalUser = new ScrapeJob(ScrapeName.queueExternalUser, queueExternalUser);

private constructor(
Expand Down

0 comments on commit abf42a3

Please sign in to comment.