Fix duplicate views creation in command (#18900)
Ensure the command doesn't fail on workspaces who got standard views seeded the 13/03
This commit is contained in:
committed by
GitHub
parent
4104b1d2bc
commit
7a1780e415
+38
-4
@@ -135,6 +135,16 @@ export class BackfillPageLayoutsCommand extends ActiveOrSuspendedWorkspacesMigra
|
||||
tabUniversalIdentifiers.has(widget.pageLayoutTabUniversalIdentifier),
|
||||
);
|
||||
|
||||
const {
|
||||
flatViewMaps: existingFlatViewMaps,
|
||||
flatViewFieldMaps: existingFlatViewFieldMaps,
|
||||
flatViewFieldGroupMaps: existingFlatViewFieldGroupMaps,
|
||||
} = await this.workspaceCacheService.getOrRecompute(workspaceId, [
|
||||
'flatViewMaps',
|
||||
'flatViewFieldMaps',
|
||||
'flatViewFieldGroupMaps',
|
||||
]);
|
||||
|
||||
const viewUniversalIdentifiers = new Set<string>();
|
||||
|
||||
const viewsToCreate = Object.values(
|
||||
@@ -146,6 +156,16 @@ export class BackfillPageLayoutsCommand extends ActiveOrSuspendedWorkspacesMigra
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
isDefined(
|
||||
existingFlatViewMaps.byUniversalIdentifier[
|
||||
view.universalIdentifier
|
||||
],
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
viewUniversalIdentifiers.add(view.universalIdentifier);
|
||||
|
||||
return true;
|
||||
@@ -155,16 +175,30 @@ export class BackfillPageLayoutsCommand extends ActiveOrSuspendedWorkspacesMigra
|
||||
standardAllFlatEntityMaps.flatViewFieldMaps.byUniversalIdentifier,
|
||||
)
|
||||
.filter(isDefined)
|
||||
.filter((viewField) =>
|
||||
viewUniversalIdentifiers.has(viewField.viewUniversalIdentifier),
|
||||
.filter(
|
||||
(viewField) =>
|
||||
viewUniversalIdentifiers.has(viewField.viewUniversalIdentifier) &&
|
||||
!isDefined(
|
||||
existingFlatViewFieldMaps.byUniversalIdentifier[
|
||||
viewField.universalIdentifier
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
const viewFieldGroupsToCreate = Object.values(
|
||||
standardAllFlatEntityMaps.flatViewFieldGroupMaps.byUniversalIdentifier,
|
||||
)
|
||||
.filter(isDefined)
|
||||
.filter((viewFieldGroup) =>
|
||||
viewUniversalIdentifiers.has(viewFieldGroup.viewUniversalIdentifier),
|
||||
.filter(
|
||||
(viewFieldGroup) =>
|
||||
viewUniversalIdentifiers.has(
|
||||
viewFieldGroup.viewUniversalIdentifier,
|
||||
) &&
|
||||
!isDefined(
|
||||
existingFlatViewFieldGroupMaps.byUniversalIdentifier[
|
||||
viewFieldGroup.universalIdentifier
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
const validateAndBuildResult =
|
||||
|
||||
Reference in New Issue
Block a user