Skip to content

Commit 4b875e7

Browse files
author
Dave Bartolomeo
committed
Merge remote-tracking branch 'origin/main' into dbartol/join-order-threshold
2 parents 9b0d4bd + 8df061f commit 4b875e7

25 files changed

+325
-119
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Fix a bug where results created in older versions were thought to be unsuccessful. [#1605](https://github.com/github/vscode-codeql/pull/1605)
6+
57
## 1.7.1 - 12 October 2022
68

79
- Fix a bug where it was not possible to add a database folder if the folder name starts with `db-`. [#1565](https://github.com/github/vscode-codeql/pull/1565)

extensions/ql-vscode/src/config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { DistributionManager } from './distribution';
44
import { logger } from './logging';
55
import { ONE_DAY_IN_MS } from './pure/time';
66

7+
export const ALL_SETTINGS: Setting[] = [];
8+
79
/** Helper class to look up a labelled (and possibly nested) setting. */
810
export class Setting {
911
name: string;
@@ -12,6 +14,7 @@ export class Setting {
1214
constructor(name: string, parent?: Setting) {
1315
this.name = name;
1416
this.parent = parent;
17+
ALL_SETTINGS.push(this);
1518
}
1619

1720
get qualifiedName(): string {
@@ -36,6 +39,18 @@ export class Setting {
3639
return workspace.getConfiguration(this.parent.qualifiedName).update(this.name, value, target);
3740
}
3841

42+
inspect<T>(): InspectionResult<T> | undefined {
43+
if (this.parent === undefined) {
44+
throw new Error('Cannot update the value of a root setting.');
45+
}
46+
return workspace.getConfiguration(this.parent.qualifiedName).inspect(this.name);
47+
}
48+
}
49+
50+
export interface InspectionResult<T> {
51+
globalValue?: T;
52+
workspaceValue?: T,
53+
workspaceFolderValue?: T,
3954
}
4055

4156
const ROOT_SETTING = new Setting('codeQL');

extensions/ql-vscode/src/databases.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ export class DatabaseManager extends DisposableObject {
559559
super();
560560

561561
qs.onStart(this.reregisterDatabases.bind(this));
562-
563-
// Let this run async.
564-
void this.loadPersistedState();
565562
}
566563

567564
public async openDatabase(
@@ -691,7 +688,7 @@ export class DatabaseManager extends DisposableObject {
691688
return item;
692689
}
693690

694-
private async loadPersistedState(): Promise<void> {
691+
public async loadPersistedState(): Promise<void> {
695692
return withProgress({
696693
location: vscode.ProgressLocation.Notification
697694
},

extensions/ql-vscode/src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ async function activateWithInstalledDistribution(
452452

453453
void logger.log('Initializing database manager.');
454454
const dbm = new DatabaseManager(ctx, qs, cliServer, logger);
455+
456+
// Let this run async.
457+
void dbm.loadPersistedState();
458+
455459
ctx.subscriptions.push(dbm);
456460
void logger.log('Initializing database panel.');
457461
const databaseUI = new DatabaseUI(

extensions/ql-vscode/src/pure/date.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,16 @@ export function formatDate(value: Date): string {
2424

2525
return dateFormatter.format(value);
2626
}
27+
28+
// These are overloads for the function that allow us to not add an extra
29+
// type check when the value is definitely not undefined.
30+
export function parseDate(value: string): Date;
31+
export function parseDate(value: string | undefined | null): Date | undefined;
32+
33+
export function parseDate(value: string | undefined | null): Date | undefined {
34+
if (value === undefined || value === null) {
35+
return undefined;
36+
}
37+
38+
return new Date(value);
39+
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CompletedQueryInfo, LocalQueryInfo } from './query-results';
77
import { QueryHistoryInfo } from './query-history-info';
88
import { QueryStatus } from './query-status';
99
import { QueryEvaluationInfo } from './run-queries-shared';
10+
import { QueryResultType } from './pure/legacy-messages';
1011

1112
export async function slurpQueryHistory(fsPath: string): Promise<QueryHistoryInfo[]> {
1213
try {
@@ -39,6 +40,17 @@ export async function slurpQueryHistory(fsPath: string): Promise<QueryHistoryInf
3940
Object.setPrototypeOf(q.completedQuery.query, QueryEvaluationInfo.prototype);
4041
// slurped queries do not need to be disposed
4142
q.completedQuery.dispose = () => { /**/ };
43+
44+
// Previously, there was a typo in the completedQuery type. There was a field
45+
// `sucessful` and it was renamed to `successful`. We need to handle this case.
46+
if ('sucessful' in q.completedQuery) {
47+
(q.completedQuery as any).successful = (q.completedQuery as any).sucessful;
48+
delete (q.completedQuery as any).sucessful;
49+
}
50+
51+
if (!('successful' in q.completedQuery)) {
52+
(q.completedQuery as any).successful = q.completedQuery.result?.resultType === QueryResultType.SUCCESS;
53+
}
4254
}
4355
} else if (q.t === 'remote') {
4456
// A bug was introduced that didn't set the completed flag in query history
@@ -91,7 +103,10 @@ export async function splatQueryHistory(queries: QueryHistoryInfo[], fsPath: str
91103
// remove incomplete local queries since they cannot be recreated on restart
92104
const filteredQueries = queries.filter(q => q.t === 'local' ? q.completedQuery !== undefined : true);
93105
const data = JSON.stringify({
94-
version: 2, // version 2 adds the `variant-analysis` type.
106+
// version 2:
107+
// - adds the `variant-analysis` type
108+
// - ensures a `successful` property exists on completedQuery
109+
version: 2,
95110
queries: filteredQueries
96111
}, null, 2);
97112
await fs.writeFile(fsPath, data);

extensions/ql-vscode/src/remote-queries/gh-api/variant-analysis.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export interface VariantAnalysis {
2424
actor_id: number,
2525
query_language: VariantAnalysisQueryLanguage,
2626
query_pack_url: string,
27+
created_at: string,
28+
updated_at: string,
2729
status: VariantAnalysisStatus,
30+
completed_at?: string,
2831
actions_workflow_run_id?: number,
2932
failure_reason?: VariantAnalysisFailureReason,
3033
scanned_repositories?: VariantAnalysisScannedRepository[],

extensions/ql-vscode/src/remote-queries/shared/variant-analysis.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ export interface VariantAnalysis {
1515
repositoryLists?: string[],
1616
repositoryOwners?: string[],
1717
},
18+
createdAt: string,
19+
updatedAt: string,
1820
executionStartTime: number;
1921
status: VariantAnalysisStatus,
22+
completedAt?: string,
2023
actionsWorkflowRunId?: number,
2124
failureReason?: VariantAnalysisFailureReason,
2225
scannedRepos?: VariantAnalysisScannedRepository[],

extensions/ql-vscode/src/remote-queries/variant-analysis-processor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export function processUpdatedVariantAnalysis(
5656
query: previousVariantAnalysis.query,
5757
databases: previousVariantAnalysis.databases,
5858
executionStartTime: previousVariantAnalysis.executionStartTime,
59+
createdAt: response.created_at,
60+
updatedAt: response.updated_at,
5961
status: processApiStatus(response.status),
62+
completedAt: response.completed_at,
6063
actionsWorkflowRunId: response.actions_workflow_run_id,
6164
scannedRepos: scannedRepos,
6265
skippedRepos: skippedRepos

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisHeader.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import {
1010
import { QueryDetails } from './QueryDetails';
1111
import { VariantAnalysisActions } from './VariantAnalysisActions';
1212
import { VariantAnalysisStats } from './VariantAnalysisStats';
13+
import { parseDate } from '../../pure/date';
1314

1415
export type VariantAnalysisHeaderProps = {
1516
variantAnalysis: VariantAnalysis;
1617

17-
duration?: number | undefined;
18-
completedAt?: Date | undefined;
19-
2018
onOpenQueryFileClick: () => void;
2119
onViewQueryTextClick: () => void;
2220

@@ -41,8 +39,6 @@ const Row = styled.div`
4139

4240
export const VariantAnalysisHeader = ({
4341
variantAnalysis,
44-
duration,
45-
completedAt,
4642
onOpenQueryFileClick,
4743
onViewQueryTextClick,
4844
onStopQueryClick,
@@ -85,8 +81,8 @@ export const VariantAnalysisHeader = ({
8581
completedRepositoryCount={completedRepositoryCount}
8682
resultCount={resultCount}
8783
hasWarnings={hasSkippedRepos}
88-
duration={duration}
89-
completedAt={completedAt}
84+
createdAt={parseDate(variantAnalysis.createdAt)}
85+
completedAt={parseDate(variantAnalysis.completedAt)}
9086
onViewLogsClick={onViewLogsClick}
9187
/>
9288
</Container>

0 commit comments

Comments
 (0)