UNPKG

@grouparoo/core

Version:
29 lines (28 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImportAssociateRecords = void 0; const plugin_1 = require("../../modules/plugin"); const import_1 = require("../../modules/ops/import"); const actionhero_1 = require("actionhero"); const clsTask_1 = require("../../classes/tasks/clsTask"); const cls_1 = require("../../modules/cls"); class ImportAssociateRecords extends clsTask_1.CLSTask { constructor() { super(...arguments); this.name = "import:associateRecords"; this.description = "ensure that imports are associated to records"; this.frequency = 1000 * 10; this.queue = "imports"; this.inputs = {}; } async runWithinTransaction() { const limit = actionhero_1.config.batchSize.imports; const delayMs = parseInt((await plugin_1.plugin.readSetting("core", "imports-retry-delay-seconds")).value) * 1000; const imports = await import_1.ImportOps.processPendingImportsForAssociation(limit, delayMs); // re-enqueue if there is more to do if (imports.length > 0) await cls_1.CLS.enqueueTask(this.name, {}); return imports.length; } } exports.ImportAssociateRecords = ImportAssociateRecords;