Skip to content

Commit

Permalink
refactor: use set to avoid duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavxc committed Apr 2, 2024
1 parent 2dc59ef commit 0f9acb1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/nocodb/src/models/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,21 +817,24 @@ export default class Model implements TableType {
}
}

// use set to avoid duplicate
const relatedModelIds = new Set<string>();

// clear all single query cache of related views
for (const col of model.columns) {
if (!isLinksOrLTAR(col)) continue;
const colOptions = await col.getColOptions<
LinkToAnotherRecordColumn | LinksColumn
>();
if (colOptions.fk_related_model_id === model.id) {
await View.clearSingleQueryCache(
colOptions.fk_related_model_id,
null,
ncMeta,
);
}
relatedModelIds.add(colOptions?.fk_related_model_id);
}

await Promise.all(
Array.from(relatedModelIds).map(async (modelId: string) => {
await View.clearSingleQueryCache(modelId, null, ncMeta);
}),
);

return true;
}

Expand Down

1 comment on commit 0f9acb1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes have been deployed. Please run the following command to verify:

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.204.9-pr-8021-20240402-1136

Please sign in to comment.