deduplicate search results from azure

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2023-08-17 11:29:29 +01:00
parent b027fe4cb3
commit 044b4f2fb1
2 changed files with 10 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-azure': patch
---
Remove duplications from Azure search before commiting the new locations to the catalog.
@@ -148,7 +148,10 @@ export class AzureDevOpsEntityProvider implements EntityProvider {
logger.info(`Discovered ${files.length} catalog files`);
const locations = files.map(key => this.createLocationSpec(key));
const targets = files.map(key => this.createObjectUrl(key));
const locations = Array.from(new Set(targets)).map(key =>
this.createLocationSpec(key),
);
await this.connection.applyMutation({
type: 'full',
@@ -165,9 +168,7 @@ export class AzureDevOpsEntityProvider implements EntityProvider {
);
}
private createLocationSpec(file: CodeSearchResultItem): LocationSpec {
const target = this.createObjectUrl(file);
private createLocationSpec(target: string): LocationSpec {
return {
type: 'url',
target: target,