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
This commit is contained in:
@ -38,7 +38,7 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner<
|
|||||||
Options extends
|
Options extends
|
||||||
ActiveOrSuspendedWorkspacesMigrationCommandOptions = ActiveOrSuspendedWorkspacesMigrationCommandOptions,
|
ActiveOrSuspendedWorkspacesMigrationCommandOptions = ActiveOrSuspendedWorkspacesMigrationCommandOptions,
|
||||||
> extends MigrationCommandRunner {
|
> extends MigrationCommandRunner {
|
||||||
private workspaceIds: string[] = [];
|
private workspaceIds: Set<string> = new Set();
|
||||||
private startFromWorkspaceId: string | undefined;
|
private startFromWorkspaceId: string | undefined;
|
||||||
private workspaceCountLimit: number | undefined;
|
private workspaceCountLimit: number | undefined;
|
||||||
public migrationReport: WorkspaceMigrationReport = {
|
public migrationReport: WorkspaceMigrationReport = {
|
||||||
@ -91,8 +91,8 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner<
|
|||||||
'workspace id. Command runs on all active workspaces if not provided.',
|
'workspace id. Command runs on all active workspaces if not provided.',
|
||||||
required: false,
|
required: false,
|
||||||
})
|
})
|
||||||
parseWorkspaceId(val: string): string[] {
|
parseWorkspaceId(val: string): Set<string> {
|
||||||
this.workspaceIds.push(val);
|
this.workspaceIds.add(val);
|
||||||
|
|
||||||
return this.workspaceIds;
|
return this.workspaceIds;
|
||||||
}
|
}
|
||||||
@ -123,8 +123,8 @@ export abstract class ActiveOrSuspendedWorkspacesMigrationCommandRunner<
|
|||||||
options: Options,
|
options: Options,
|
||||||
) {
|
) {
|
||||||
const activeWorkspaceIds =
|
const activeWorkspaceIds =
|
||||||
this.workspaceIds.length > 0
|
this.workspaceIds.size > 0
|
||||||
? this.workspaceIds
|
? Array.from(this.workspaceIds)
|
||||||
: await this.fetchActiveWorkspaceIds();
|
: await this.fetchActiveWorkspaceIds();
|
||||||
|
|
||||||
if (options.dryRun) {
|
if (options.dryRun) {
|
||||||
|
|||||||
Reference in New Issue
Block a user