mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
refactor(core): Remove deprecated TIME
constant (#11740)
This commit is contained in:
parent
fb123b44af
commit
f4f0b5110c
|
@ -110,25 +110,12 @@ export const UM_FIX_INSTRUCTION =
|
|||
'Please fix the database by running ./packages/cli/bin/n8n user-management:reset';
|
||||
|
||||
/**
|
||||
* Units of time in milliseconds
|
||||
* @deprecated Please use constants.Time instead.
|
||||
*/
|
||||
export const TIME = {
|
||||
SECOND: 1000,
|
||||
MINUTE: 60 * 1000,
|
||||
HOUR: 60 * 60 * 1000,
|
||||
DAY: 24 * 60 * 60 * 1000,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Convert time from any unit to any other unit
|
||||
*
|
||||
* Please amend conversions as necessary.
|
||||
* Eventually this will superseed `TIME` above
|
||||
* Convert time from any time unit to any other unit
|
||||
*/
|
||||
export const Time = {
|
||||
milliseconds: {
|
||||
toMinutes: 1 / (60 * 1000),
|
||||
toSeconds: 1 / 1000,
|
||||
},
|
||||
seconds: {
|
||||
toMilliseconds: 1000,
|
||||
|
@ -150,9 +137,9 @@ export const MIN_PASSWORD_CHAR_LENGTH = 8;
|
|||
|
||||
export const MAX_PASSWORD_CHAR_LENGTH = 64;
|
||||
|
||||
export const TEST_WEBHOOK_TIMEOUT = 2 * TIME.MINUTE;
|
||||
export const TEST_WEBHOOK_TIMEOUT = 2 * Time.minutes.toMilliseconds;
|
||||
|
||||
export const TEST_WEBHOOK_TIMEOUT_BUFFER = 30 * TIME.SECOND;
|
||||
export const TEST_WEBHOOK_TIMEOUT_BUFFER = 30 * Time.seconds.toMilliseconds;
|
||||
|
||||
export const GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE = [
|
||||
'oAuth2Api',
|
||||
|
|
|
@ -3,7 +3,7 @@ import { InstanceSettings } from 'n8n-core';
|
|||
import { Service } from 'typedi';
|
||||
|
||||
import config from '@/config';
|
||||
import { TIME } from '@/constants';
|
||||
import { Time } from '@/constants';
|
||||
import { Logger } from '@/logging/logger.service';
|
||||
import { Publisher } from '@/scaling/pubsub/publisher.service';
|
||||
import { RedisClientService } from '@/services/redis-client.service';
|
||||
|
@ -54,7 +54,7 @@ export class MultiMainSetup extends TypedEmitter<MultiMainEvents> {
|
|||
|
||||
this.leaderCheckInterval = setInterval(async () => {
|
||||
await this.checkLeader();
|
||||
}, this.globalConfig.multiMainSetup.interval * TIME.SECOND);
|
||||
}, this.globalConfig.multiMainSetup.interval * Time.seconds.toMilliseconds);
|
||||
}
|
||||
|
||||
async shutdown() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { ApplicationError, jsonStringify } from 'n8n-workflow';
|
|||
import Container, { Service } from 'typedi';
|
||||
|
||||
import config from '@/config';
|
||||
import { TIME } from '@/constants';
|
||||
import { Time } from '@/constants';
|
||||
import { MalformedRefreshValueError } from '@/errors/cache-errors/malformed-refresh-value.error';
|
||||
import { UncacheableValueError } from '@/errors/cache-errors/uncacheable-value.error';
|
||||
import type {
|
||||
|
@ -160,7 +160,7 @@ export class CacheService extends TypedEmitter<CacheEvents> {
|
|||
});
|
||||
}
|
||||
|
||||
await this.cache.store.expire(key, ttlMs / TIME.SECOND);
|
||||
await this.cache.store.expire(key, ttlMs * Time.milliseconds.toSeconds);
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import { TIME } from '@/constants';
|
||||
|
||||
export const WORKFLOW_HISTORY_PRUNE_INTERVAL = 1 * TIME.HOUR;
|
|
@ -1,9 +1,9 @@
|
|||
import { DateTime } from 'luxon';
|
||||
import { Service } from 'typedi';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository';
|
||||
|
||||
import { WORKFLOW_HISTORY_PRUNE_INTERVAL } from './constants';
|
||||
import {
|
||||
getWorkflowHistoryPruneTime,
|
||||
isWorkflowHistoryEnabled,
|
||||
|
@ -20,7 +20,7 @@ export class WorkflowHistoryManager {
|
|||
clearInterval(this.pruneTimer);
|
||||
}
|
||||
|
||||
this.pruneTimer = setInterval(async () => await this.prune(), WORKFLOW_HISTORY_PRUNE_INTERVAL);
|
||||
this.pruneTimer = setInterval(async () => await this.prune(), 1 * Time.hours.toMilliseconds);
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { BinaryDataService, InstanceSettings } from 'n8n-core';
|
|||
import type { ExecutionStatus } from 'n8n-workflow';
|
||||
import Container from 'typedi';
|
||||
|
||||
import { TIME } from '@/constants';
|
||||
import { Time } from '@/constants';
|
||||
import type { ExecutionEntity } from '@/databases/entities/execution-entity';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
|
||||
|
@ -25,7 +25,7 @@ describe('softDeleteOnPruningCycle()', () => {
|
|||
instanceSettings.markAsLeader();
|
||||
|
||||
const now = new Date();
|
||||
const yesterday = new Date(Date.now() - TIME.DAY);
|
||||
const yesterday = new Date(Date.now() - 1 * Time.days.toMilliseconds);
|
||||
let workflow: WorkflowEntity;
|
||||
let pruningConfig: PruningConfig;
|
||||
|
||||
|
|
Loading…
Reference in a new issue