@grouparoo/core
Version:
The Grouparoo Core
28 lines (27 loc) • 894 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.internalRun = void 0;
const Run_1 = require("../models/Run");
/**
* This method creates a new Run for internal use, ie: when you want to create a run due to a new Property
* This method will enqueue a run which creates an import for every record
* Enqueuing a new internal run will end any previous runs for the same creator type
*/
async function internalRun(creatorType, creatorId) {
const previousRuns = await Run_1.Run.findAll({
where: {
creatorType,
state: "running",
},
});
for (const previousRun of previousRuns)
await previousRun.stop();
const run = await Run_1.Run.create({
creatorType,
creatorId,
state: "running",
method: "internalRun",
});
return run;
}
exports.internalRun = internalRun;