From 6c035ede8ae7469e4645f372eb52bf2603a9e739 Mon Sep 17 00:00:00 2001 From: "Abdullah." <125115953+mabdullahabaid@users.noreply.github.com> Date: Thu, 16 Oct 2025 16:33:53 +0500 Subject: [PATCH] Ensure one export per file for constants of trash-cleanup. (#15110) Had three constant exports in one file, thus breaking the codebase pattern. Moved them to their separate files and fixed imports. --- .../trash-cleanup/commands/trash-cleanup.cron.command.ts | 2 +- .../constants/trash-cleanup-batch-size.constant.ts | 1 + .../constants/trash-cleanup-cron-pattern.constant.ts | 1 + .../trash-cleanup-max-records-per-workspace.constant.ts | 1 + .../trash-cleanup/constants/trash-cleanup.constants.ts | 5 ----- .../engine/trash-cleanup/crons/trash-cleanup.cron.job.ts | 2 +- .../engine/trash-cleanup/services/trash-cleanup.service.ts | 6 ++---- 7 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-batch-size.constant.ts create mode 100644 packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant.ts create mode 100644 packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-max-records-per-workspace.constant.ts delete mode 100644 packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup.constants.ts diff --git a/packages/twenty-server/src/engine/trash-cleanup/commands/trash-cleanup.cron.command.ts b/packages/twenty-server/src/engine/trash-cleanup/commands/trash-cleanup.cron.command.ts index ced36075ef4..f3b42a98f4e 100644 --- a/packages/twenty-server/src/engine/trash-cleanup/commands/trash-cleanup.cron.command.ts +++ b/packages/twenty-server/src/engine/trash-cleanup/commands/trash-cleanup.cron.command.ts @@ -3,7 +3,7 @@ import { Command, CommandRunner } from 'nest-commander'; import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator'; import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants'; import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service'; -import { TRASH_CLEANUP_CRON_PATTERN } from 'src/engine/trash-cleanup/constants/trash-cleanup.constants'; +import { TRASH_CLEANUP_CRON_PATTERN } from 'src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant'; import { TrashCleanupCronJob } from 'src/engine/trash-cleanup/crons/trash-cleanup.cron.job'; @Command({ diff --git a/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-batch-size.constant.ts b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-batch-size.constant.ts new file mode 100644 index 00000000000..f4116463d33 --- /dev/null +++ b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-batch-size.constant.ts @@ -0,0 +1 @@ +export const TRASH_CLEANUP_BATCH_SIZE = 1_000; diff --git a/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant.ts b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant.ts new file mode 100644 index 00000000000..36d94e6785f --- /dev/null +++ b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant.ts @@ -0,0 +1 @@ +export const TRASH_CLEANUP_CRON_PATTERN = '10 0 * * *'; diff --git a/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-max-records-per-workspace.constant.ts b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-max-records-per-workspace.constant.ts new file mode 100644 index 00000000000..d1008fe8a93 --- /dev/null +++ b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup-max-records-per-workspace.constant.ts @@ -0,0 +1 @@ +export const TRASH_CLEANUP_MAX_RECORDS_PER_WORKSPACE = 1_000_000; diff --git a/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup.constants.ts b/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup.constants.ts deleted file mode 100644 index ba74a0839db..00000000000 --- a/packages/twenty-server/src/engine/trash-cleanup/constants/trash-cleanup.constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Daily at 00:10 UTC -export const TRASH_CLEANUP_CRON_PATTERN = '10 0 * * *'; - -export const TRASH_CLEANUP_MAX_RECORDS_PER_WORKSPACE = 1_000_000; -export const TRASH_CLEANUP_BATCH_SIZE = 1_000; diff --git a/packages/twenty-server/src/engine/trash-cleanup/crons/trash-cleanup.cron.job.ts b/packages/twenty-server/src/engine/trash-cleanup/crons/trash-cleanup.cron.job.ts index 41c67bd7f24..0a840f41532 100644 --- a/packages/twenty-server/src/engine/trash-cleanup/crons/trash-cleanup.cron.job.ts +++ b/packages/twenty-server/src/engine/trash-cleanup/crons/trash-cleanup.cron.job.ts @@ -12,7 +12,7 @@ import { Processor } from 'src/engine/core-modules/message-queue/decorators/proc import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants'; import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; -import { TRASH_CLEANUP_CRON_PATTERN } from 'src/engine/trash-cleanup/constants/trash-cleanup.constants'; +import { TRASH_CLEANUP_CRON_PATTERN } from 'src/engine/trash-cleanup/constants/trash-cleanup-cron-pattern.constant'; import { TrashCleanupJob, type TrashCleanupJobData, diff --git a/packages/twenty-server/src/engine/trash-cleanup/services/trash-cleanup.service.ts b/packages/twenty-server/src/engine/trash-cleanup/services/trash-cleanup.service.ts index 1d044f75f7b..1728d0e2998 100644 --- a/packages/twenty-server/src/engine/trash-cleanup/services/trash-cleanup.service.ts +++ b/packages/twenty-server/src/engine/trash-cleanup/services/trash-cleanup.service.ts @@ -4,10 +4,8 @@ import { isDefined } from 'twenty-shared/utils'; import { In, LessThan } from 'typeorm'; import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service'; -import { - TRASH_CLEANUP_BATCH_SIZE, - TRASH_CLEANUP_MAX_RECORDS_PER_WORKSPACE, -} from 'src/engine/trash-cleanup/constants/trash-cleanup.constants'; +import { TRASH_CLEANUP_BATCH_SIZE } from 'src/engine/trash-cleanup/constants/trash-cleanup-batch-size.constant'; +import { TRASH_CLEANUP_MAX_RECORDS_PER_WORKSPACE } from 'src/engine/trash-cleanup/constants/trash-cleanup-max-records-per-workspace.constant'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; export type TrashCleanupInput = {