Merge pull request #31763 from drodil/refresh_ancestry

fix(catalog): fix refresh service ancestry to follow the tree
This commit is contained in:
Fredrik Adelöw
2025-12-16 14:54:44 +01:00
committed by GitHub
2 changed files with 10 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Fixed default refresh service to go through the whole ancestry of the entity.
@@ -29,20 +29,17 @@ export class DefaultRefreshService implements RefreshService {
const { entityRefs } = await this.database.listAncestors(tx, {
entityRef: options.entityRef,
});
const locationAncestor = entityRefs.find(ref =>
const locationAncestors = entityRefs.filter(ref =>
ref.startsWith('location:'),
);
// TODO: Refreshes are currently scheduled(as soon as possible) for execution and will therefore happen in the future.
// There's room for improvements here where the refresh could potentially hang or return an ID so that the user can check progress.
if (locationAncestor) {
await this.database.refresh(tx, {
entityRef: locationAncestor,
});
for (const locationAncestor of locationAncestors) {
await this.database.refresh(tx, { entityRef: locationAncestor });
}
await this.database.refresh(tx, {
entityRef: options.entityRef,
});
await this.database.refresh(tx, { entityRef: options.entityRef });
});
}
}