Skip to content

Commit a21dec7

Browse files
committed
Fix label text
In [1] we changed our factory methods to actually use QueryStatus when creating remote query & variant analysis history items. Previously we were just setting the value to `in progress`... ... which made the tests for history-item-label-provider.test.ts pass... ... but that value did not reflect reality ... What we actually need to do is introduce a method to map different query statuses to human readable strings, e.g. QueryStatus.InProgress becomes 'in progress' [1]: 4b9db6a#diff-217b085c45cd008d938c3da4714b5782db6ad31438b27b07e969254feec8298aL28
1 parent 8cfa82f commit a21dec7

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

extensions/ql-vscode/src/history-item-label-provider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-it
77
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
88
import { assertNever } from './pure/helpers-pure';
99
import { pluralize } from './pure/word';
10+
import { humanizeQueryStatus } from './query-status';
1011

1112
interface InterpolateReplacements {
1213
t: string; // Start time
@@ -86,7 +87,7 @@ export class HistoryItemLabelProvider {
8687
q: `${item.remoteQuery.queryName} (${item.remoteQuery.language})`,
8788
d: buildRepoLabel(item),
8889
r: resultCount,
89-
s: item.status,
90+
s: humanizeQueryStatus(item.status),
9091
f: path.basename(item.remoteQuery.queryFilePath),
9192
'%': '%'
9293
};
@@ -99,7 +100,7 @@ export class HistoryItemLabelProvider {
99100
q: `${item.variantAnalysis.query.name} (${item.variantAnalysis.query.language})`,
100101
d: buildRepoLabel(item),
101102
r: resultCount,
102-
s: item.status,
103+
s: humanizeQueryStatus(item.status),
103104
f: path.basename(item.variantAnalysis.query.filePath),
104105
'%': '%',
105106
};

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ export function variantAnalysisStatusToQueryStatus(status: VariantAnalysisStatus
2121
assertNever(status);
2222
}
2323
}
24+
25+
export function humanizeQueryStatus(status: QueryStatus): string {
26+
switch (status) {
27+
case QueryStatus.InProgress:
28+
return 'in progress';
29+
case QueryStatus.Completed:
30+
return 'completed';
31+
case QueryStatus.Failed:
32+
return 'failed';
33+
default:
34+
return 'unknown';
35+
}
36+
}

extensions/ql-vscode/src/vscode-tests/no-workspace/history-item-label-provider.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { HistoryItemLabelProvider } from '../../history-item-label-provider';
55
import { createMockLocalQueryInfo } from '../factories/local-queries/local-query-history-item';
66
import { createMockRemoteQueryHistoryItem } from '../factories/remote-queries/remote-query-history-item';
77

8-
98
describe('HistoryItemLabelProvider', () => {
10-
119
let labelProvider: HistoryItemLabelProvider;
1210
let config: QueryHistoryConfig;
1311
const date = new Date('2022-01-01T00:00:00.000Z');

0 commit comments

Comments
 (0)