Skip to content

Commit 99a784f

Browse files
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>
1 parent 030488a commit 99a784f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

extensions/ql-vscode/src/query-history.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,12 @@ export class HistoryTreeDataProvider extends DisposableObject {
205205
? h2.initialInfo.start.getTime()
206206
: h2.remoteQuery?.executionStartTime;
207207

208-
// result count for remote queries is not available here.
209208
const resultCount1 = h1.t === 'local'
210209
? h1.completedQuery?.resultCount ?? -1
211-
: -1;
210+
: h1.resultCount ?? -1;
212211
const resultCount2 = h2.t === 'local'
213212
? h2.completedQuery?.resultCount ?? -1
214-
: -1;
213+
: h2.resultCount ?? -1;
215214

216215
switch (this.sortOrder) {
217216
case SortOrder.NameAsc:

extensions/ql-vscode/src/vscode-tests/no-workspace/query-history.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,11 @@ describe('query-history', () => {
456456

457457
describe('getChildren', () => {
458458
const history = [
459-
item('a', 2, 'remote'),
459+
item('a', 2, 'remote', 24),
460460
item('b', 10, 'local', 20),
461461
item('c', 5, 'local', 30),
462462
item('d', 1, 'local', 25),
463-
item('e', 6, 'remote'),
463+
item('e', 6, 'remote', 5),
464464
];
465465
let treeDataProvider: HistoryTreeDataProvider;
466466

@@ -503,15 +503,15 @@ describe('query-history', () => {
503503
});
504504

505505
it('should get children for result count ascending', async () => {
506-
const expected = [history[0], history[4], history[1], history[3], history[2]];
506+
const expected = [history[4], history[1], history[0], history[3], history[2]];
507507
treeDataProvider.sortOrder = SortOrder.CountAsc;
508508

509509
const children = await treeDataProvider.getChildren();
510510
expect(children).to.deep.eq(expected);
511511
});
512512

513513
it('should get children for result count descending', async () => {
514-
const expected = [history[0], history[4], history[1], history[3], history[2]].reverse();
514+
const expected = [history[4], history[1], history[0], history[3], history[2]].reverse();
515515
treeDataProvider.sortOrder = SortOrder.CountDesc;
516516

517517
const children = await treeDataProvider.getChildren();
@@ -573,6 +573,7 @@ describe('query-history', () => {
573573
},
574574
repositories: []
575575
},
576+
resultCount,
576577
t
577578
};
578579
}

0 commit comments

Comments
 (0)