n8n
Version:
n8n Workflow Automation Tool
51 lines • 2.5 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkflowHistoryManager = void 0;
const typedi_1 = require("typedi");
const luxon_1 = require("luxon");
const workflowHistory_repository_1 = require("../../databases/repositories/workflowHistory.repository");
const constants_1 = require("./constants");
const workflowHistoryHelper_ee_1 = require("./workflowHistoryHelper.ee");
let WorkflowHistoryManager = class WorkflowHistoryManager {
constructor(workflowHistoryRepo) {
this.workflowHistoryRepo = workflowHistoryRepo;
}
init() {
if (this.pruneTimer !== undefined) {
clearInterval(this.pruneTimer);
}
this.pruneTimer = setInterval(async () => await this.prune(), constants_1.WORKFLOW_HISTORY_PRUNE_INTERVAL);
}
shutdown() {
if (this.pruneTimer !== undefined) {
clearInterval(this.pruneTimer);
this.pruneTimer = undefined;
}
}
async prune() {
if (!(0, workflowHistoryHelper_ee_1.isWorkflowHistoryEnabled)()) {
return;
}
const pruneHours = (0, workflowHistoryHelper_ee_1.getWorkflowHistoryPruneTime)();
if (pruneHours === -1) {
return;
}
const pruneDateTime = luxon_1.DateTime.now().minus({ hours: pruneHours }).toJSDate();
await this.workflowHistoryRepo.deleteEarlierThan(pruneDateTime);
}
};
exports.WorkflowHistoryManager = WorkflowHistoryManager;
exports.WorkflowHistoryManager = WorkflowHistoryManager = __decorate([
(0, typedi_1.Service)(),
__metadata("design:paramtypes", [workflowHistory_repository_1.WorkflowHistoryRepository])
], WorkflowHistoryManager);
//# sourceMappingURL=workflowHistoryManager.ee.js.map
;