UNPKG

@grouparoo/core

Version:
31 lines (30 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GrouparooRecordsMakeReady = void 0; const actionhero_1 = require("actionhero"); const clsTask_1 = require("../../classes/tasks/clsTask"); const cls_1 = require("../../modules/cls"); const record_1 = require("../../modules/ops/record"); class GrouparooRecordsMakeReady extends clsTask_1.CLSTask { constructor() { super(...arguments); this.name = "records:makeReady"; this.description = "If all of a GrouparooRecord's Properties are ready, mark the record ready and start the export"; this.frequency = 1000 * 10; this.queue = "records"; this.inputs = {}; } async runWithinTransaction() { const limit = actionhero_1.config.batchSize.imports; const toExport = process.env.GROUPAROO_DISABLE_EXPORTS ? process.env.GROUPAROO_DISABLE_EXPORTS !== "true" : true; const partialRecords = await record_1.RecordOps.makeReady(limit); await record_1.RecordOps.makeExports(partialRecords.map((r) => r.id), toExport); // re-enqueue if there is more to do if (partialRecords.length > 0) await cls_1.CLS.enqueueTask(this.name, {}); return partialRecords.length; } } exports.GrouparooRecordsMakeReady = GrouparooRecordsMakeReady;