From a78f3f0d89ae77b109f0a09bffabb4f8bf4b9d61 Mon Sep 17 00:00:00 2001 From: Paul Rastoin <45004772+prastoin@users.noreply.github.com> Date: Wed, 7 May 2025 16:45:16 +0200 Subject: [PATCH] Fix duplicated workspace id in activeOrSuspendedCommandRunner options (#11903) # Introduction From my understand we're kinda hacking through the options parser by defining class properties within them whereas we should be consuming the return type value ? Have no time for this right now Anw for some reason nestjs-commander enters several time the option parse which result in duplicating the given workspaceId in the array Added a Set to fix close https://github.com/twentyhq/twenty/issues/11707 --- ...or-suspended-workspaces-migration.command-runner.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/twenty-server/src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner.ts b/packages/twenty-server/src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner.ts index 6e4a4a090..53c7dd75f 100644 --- a/packages/twenty-server/src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner.ts +++ b/packages/twenty-server/src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner.ts @@ -38,7 +38,7 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner< Options extends ActiveOrSuspendedWorkspacesMigrationCommandOptions = ActiveOrSuspendedWorkspacesMigrationCommandOptions, > extends MigrationCommandRunner { - private workspaceIds: string[] = []; + private workspaceIds: Set = new Set(); private startFromWorkspaceId: string | undefined; private workspaceCountLimit: number | undefined; public migrationReport: WorkspaceMigrationReport = { @@ -91,8 +91,8 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner< 'workspace id. Command runs on all active workspaces if not provided.', required: false, }) - parseWorkspaceId(val: string): string[] { - this.workspaceIds.push(val); + parseWorkspaceId(val: string): Set { + this.workspaceIds.add(val); return this.workspaceIds; } @@ -123,8 +123,8 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner< options: Options, ) { const activeWorkspaceIds = - this.workspaceIds.length > 0 - ? this.workspaceIds + this.workspaceIds.size > 0 + ? Array.from(this.workspaceIds) : await this.fetchActiveWorkspaceIds(); if (options.dryRun) {