Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinr committed Sep 3, 2024
1 parent 6d24eba commit e61b619
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/server/src/sdk/app/views/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
FieldType,
RelationSchemaField,
RelationshipFieldMetadata,
RenameColumn,
Table,
TableSchema,
Expand Down Expand Up @@ -255,18 +254,20 @@ export function syncSchema(
}

export async function renameLinkedViews(table: Table, renaming: RenameColumn) {
const relatedLinks: Record<string, RelationshipFieldMetadata[]> = {}
const relatedTableIds = new Set<string>()

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(
Expand Down

0 comments on commit e61b619

Please sign in to comment.