Reformat pruning date to UTC string

This commit is contained in:
Iván Ovejero 2021-06-30 11:21:36 +02:00
parent 65e6d7c0f8
commit f096136c37

View file

@ -46,6 +46,7 @@ import {
import * as config from '../config';
import { LessThanOrEqual } from 'typeorm';
import { DateUtils } from 'typeorm/util/DateUtils';
const ERROR_TRIGGER_TYPE = config.get('nodes.errorTriggerType') as string;
@ -112,8 +113,11 @@ function pruneExecutionData(this: WorkflowHooks): void {
const date = new Date(); // today
date.setHours(date.getHours() - maxAge);
// date reformatting needed - see https://github.com/typeorm/typeorm/issues/2286
const utcDate = DateUtils.mixedDateToUtcDatetimeString(date);
// throttle just on success to allow for self healing on failure
Db.collections.Execution!.delete({ stoppedAt: LessThanOrEqual(date.toISOString()) })
Db.collections.Execution!.delete({ stoppedAt: LessThanOrEqual(utcDate) })
.then(data =>
setTimeout(() => {
throttling = false;