fix: Document subscriptions backfill not recursive

This commit is contained in:
Tom Moor
2022-08-27 11:58:21 +02:00
parent 1c8fadbe02
commit 922bf53753
2 changed files with 12 additions and 13 deletions

View File

@@ -1,12 +1,12 @@
import "./bootstrap";
import { Subscription, Document } from "@server/models";
const limit = 100;
const limit = 1000;
let page = parseInt(process.argv[2], 10);
page = Number.isNaN(page) ? 0 : page;
export default async function main(exit = false) {
const work = async (page: number) => {
const work = async (page: number): Promise<void> => {
console.log(`Backfill subscription… page ${page}`);
// Retrieve all documents within set limit.
@@ -36,6 +36,8 @@ export default async function main(exit = false) {
continue;
}
}
return documents.length === limit ? work(page + 1) : undefined;
};
await work(page);