fix(catalog): fix refresh service ancestry to follow the tree
if location is referenced by another location, that will not get updated properly Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user