diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts index 7cc543299..f9e1d2fc9 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts @@ -278,7 +278,8 @@ export class CleanerWorkspaceService { if ( daysSinceSoftDeleted > - this.inactiveDaysBeforeDelete - this.inactiveDaysBeforeSoftDelete + this.inactiveDaysBeforeDelete - this.inactiveDaysBeforeSoftDelete && + deletedWorkspacesCount < this.maxNumberOfWorkspacesDeletedPerExecution ) { this.logger.log( `${dryRun ? 'DRY RUN - ' : ''}Destroying workspace ${workspace.id} ${workspace.displayName}`, @@ -286,20 +287,16 @@ export class CleanerWorkspaceService { if (!dryRun) { await this.workspaceService.deleteWorkspace(workspace.id); } + deletedWorkspacesCount++; continue; } - if ( - workspaceInactivity > this.inactiveDaysBeforeSoftDelete && - deletedWorkspacesCount <= - this.maxNumberOfWorkspacesDeletedPerExecution - ) { + if (workspaceInactivity > this.inactiveDaysBeforeSoftDelete) { await this.informWorkspaceMembersAndSoftDeleteWorkspace( workspace, workspaceInactivity, dryRun, ); - deletedWorkspacesCount++; continue; }