From e61b61974073a3b902fd7c6785a382472495ab32 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Sep 2024 10:43:44 +0200 Subject: [PATCH] Clean code --- packages/server/src/sdk/app/views/index.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 120b56183c4..b90c308ead8 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -1,7 +1,6 @@ import { FieldType, RelationSchemaField, - RelationshipFieldMetadata, RenameColumn, Table, TableSchema, @@ -255,18 +254,20 @@ export function syncSchema( } export async function renameLinkedViews(table: Table, renaming: RenameColumn) { - const relatedLinks: Record = {} + const relatedTableIds = new Set() for (const field of Object.values(table.schema)) { if (field.type !== FieldType.LINK) { continue } - relatedLinks[field.tableId] ??= [] - relatedLinks[field.tableId].push(field) + relatedTableIds.add(field.tableId) + break } - const relatedTables = await sdk.tables.getTables(Object.keys(relatedLinks)) + const relatedTables = await sdk.tables.getTables( + Array.from(relatedTableIds.values()) + ) for (const relatedTable of relatedTables) { let toSave = false const viewsV2 = Object.values(relatedTable.views || {}).filter(