Be able to sort remote queries by number of results

Previously we would set all remote query results to -1 when someone
attempted to sort queries.

We would then only sort local queries as those had access to the number
of results.

Let's include number of results for remote queries in the sorting.

Co-authored-by: Shati Patel <shati-patel@github.com>
This commit is contained in:
Elena Tanasoiu
2022-07-18 16:39:59 +01:00
parent 030488a459
commit 99a784f072
2 changed files with 7 additions and 7 deletions

View File

@@ -205,13 +205,12 @@ export class HistoryTreeDataProvider extends DisposableObject {
? h2.initialInfo.start.getTime()
: h2.remoteQuery?.executionStartTime;
// result count for remote queries is not available here.
const resultCount1 = h1.t === 'local'
? h1.completedQuery?.resultCount ?? -1
: -1;
: h1.resultCount ?? -1;
const resultCount2 = h2.t === 'local'
? h2.completedQuery?.resultCount ?? -1
: -1;
: h2.resultCount ?? -1;
switch (this.sortOrder) {
case SortOrder.NameAsc:

View File

@@ -456,11 +456,11 @@ describe('query-history', () => {
describe('getChildren', () => {
const history = [
item('a', 2, 'remote'),
item('a', 2, 'remote', 24),
item('b', 10, 'local', 20),
item('c', 5, 'local', 30),
item('d', 1, 'local', 25),
item('e', 6, 'remote'),
item('e', 6, 'remote', 5),
];
let treeDataProvider: HistoryTreeDataProvider;
@@ -503,7 +503,7 @@ describe('query-history', () => {
});
it('should get children for result count ascending', async () => {
const expected = [history[0], history[4], history[1], history[3], history[2]];
const expected = [history[4], history[1], history[0], history[3], history[2]];
treeDataProvider.sortOrder = SortOrder.CountAsc;
const children = await treeDataProvider.getChildren();
@@ -511,7 +511,7 @@ describe('query-history', () => {
});
it('should get children for result count descending', async () => {
const expected = [history[0], history[4], history[1], history[3], history[2]].reverse();
const expected = [history[4], history[1], history[0], history[3], history[2]].reverse();
treeDataProvider.sortOrder = SortOrder.CountDesc;
const children = await treeDataProvider.getChildren();
@@ -573,6 +573,7 @@ describe('query-history', () => {
},
repositories: []
},
resultCount,
t
};
}