From 94f96508491d22859c1353eda353cb39cb3c0c1d Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Mon, 21 Aug 2023 09:21:17 +0100 Subject: [PATCH 1/2] Imporve consistency of results from azure provider The search feature does not produce consistent results across api pages. This seems to be more likely if the pages are sorted by rank. This changes the sort order, in order to make the pages a little bit more consistent as the search index in azure changes. Signed-off-by: Brian Fletcher --- .changeset/fair-paws-flash.md | 5 +++++ plugins/catalog-backend-module-azure/src/lib/azure.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/fair-paws-flash.md diff --git a/.changeset/fair-paws-flash.md b/.changeset/fair-paws-flash.md new file mode 100644 index 0000000000..d9a7b1827e --- /dev/null +++ b/.changeset/fair-paws-flash.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-azure': patch +--- + +Improve consistency of results from the `AzureDevOpsEntityProvider`. diff --git a/plugins/catalog-backend-module-azure/src/lib/azure.ts b/plugins/catalog-backend-module-azure/src/lib/azure.ts index 916d70a9fa..74667c5465 100644 --- a/plugins/catalog-backend-module-azure/src/lib/azure.ts +++ b/plugins/catalog-backend-module-azure/src/lib/azure.ts @@ -64,6 +64,12 @@ export async function codeSearch( method: 'POST', body: JSON.stringify({ searchText: `path:${path} repo:${repo || '*'} proj:${project || '*'}`, + $orderBy: [ + { + field: 'path', + sortOrder: 'ASC', + }, + ], $skip: items.length, $top: PAGE_SIZE, }), From a3dc26fb402fcdc2fc649e99ec484ad5aadc8787 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Mon, 21 Aug 2023 10:22:58 +0100 Subject: [PATCH 2/2] fix tests Signed-off-by: Brian Fletcher --- .../src/lib/azure.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugins/catalog-backend-module-azure/src/lib/azure.test.ts b/plugins/catalog-backend-module-azure/src/lib/azure.test.ts index f26208353a..844258ed7e 100644 --- a/plugins/catalog-backend-module-azure/src/lib/azure.test.ts +++ b/plugins/catalog-backend-module-azure/src/lib/azure.test.ts @@ -34,6 +34,12 @@ describe('azure', () => { expect(req.headers.get('Authorization')).toBe('Basic OkFCQw=='); expect(req.body).toEqual({ searchText: 'path:/catalog-info.yaml repo:* proj:engineering', + $orderBy: [ + { + field: 'path', + sortOrder: 'ASC', + }, + ], $skip: 0, $top: 1000, }); @@ -88,6 +94,12 @@ describe('azure', () => { expect(req.headers.get('Authorization')).toBe('Basic OkFCQw=='); expect(req.body).toEqual({ searchText: 'path:/catalog-info.yaml repo:* proj:engineering', + $orderBy: [ + { + field: 'path', + sortOrder: 'ASC', + }, + ], $skip: 0, $top: 1000, }); @@ -132,6 +144,12 @@ describe('azure', () => { expect(req.body).toEqual({ searchText: 'path:/catalog-info.yaml repo:backstage proj:engineering', + $orderBy: [ + { + field: 'path', + sortOrder: 'ASC', + }, + ], $skip: 0, $top: 1000, }); @@ -175,6 +193,12 @@ describe('azure', () => { expect(req.headers.get('Authorization')).toBe('Basic OkFCQw=='); expect(req.body).toEqual({ searchText: 'path:/catalog-info.yaml repo:* proj:engineering', + $orderBy: [ + { + field: 'path', + sortOrder: 'ASC', + }, + ], $skip: 0, $top: 1000, });