Merge pull request #1848 from github/nora/db-module-initialization
Initialize DbManager when newQueryRun is enabled
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { window } from "vscode";
|
import { window } from "vscode";
|
||||||
import { App, AppMode } from "../common/app";
|
import { App } from "../common/app";
|
||||||
import { isCanary, isNewQueryRunExperienceEnabled } from "../config";
|
|
||||||
import { extLogger } from "../common";
|
import { extLogger } from "../common";
|
||||||
import { DisposableObject } from "../pure/disposable-object";
|
import { DisposableObject } from "../pure/disposable-object";
|
||||||
import { DbConfigStore } from "./config/db-config-store";
|
import { DbConfigStore } from "./config/db-config-store";
|
||||||
@@ -19,18 +18,7 @@ export class DbModule extends DisposableObject {
|
|||||||
this.dbManager = new DbManager(app, this.dbConfigStore);
|
this.dbManager = new DbManager(app, this.dbConfigStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initialize(app: App): Promise<void> {
|
public async initialize(): Promise<void> {
|
||||||
if (
|
|
||||||
app.mode !== AppMode.Development ||
|
|
||||||
!isCanary() ||
|
|
||||||
!isNewQueryRunExperienceEnabled()
|
|
||||||
) {
|
|
||||||
// Currently, we only want to expose the new database panel when we
|
|
||||||
// are in development and canary mode and the developer has enabled the
|
|
||||||
// new query run experience.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void extLogger.log("Initializing database module");
|
void extLogger.log("Initializing database module");
|
||||||
|
|
||||||
await this.dbConfigStore.initialize();
|
await this.dbConfigStore.initialize();
|
||||||
@@ -49,6 +37,6 @@ export class DbModule extends DisposableObject {
|
|||||||
|
|
||||||
export async function initializeDbModule(app: App): Promise<DbModule> {
|
export async function initializeDbModule(app: App): Promise<DbModule> {
|
||||||
const dbModule = new DbModule(app);
|
const dbModule = new DbModule(app);
|
||||||
await dbModule.initialize(app);
|
await dbModule.initialize();
|
||||||
return dbModule;
|
return dbModule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {
|
|||||||
CliConfigListener,
|
CliConfigListener,
|
||||||
DistributionConfigListener,
|
DistributionConfigListener,
|
||||||
isCanary,
|
isCanary,
|
||||||
|
isNewQueryRunExperienceEnabled,
|
||||||
isVariantAnalysisLiveResultsEnabled,
|
isVariantAnalysisLiveResultsEnabled,
|
||||||
joinOrderWarningThreshold,
|
joinOrderWarningThreshold,
|
||||||
MAX_QUERIES,
|
MAX_QUERIES,
|
||||||
@@ -138,6 +139,7 @@ import { VariantAnalysisResultsManager } from "./remote-queries/variant-analysis
|
|||||||
import { initializeDbModule } from "./databases/db-module";
|
import { initializeDbModule } from "./databases/db-module";
|
||||||
import { ExtensionApp } from "./common/vscode/vscode-app";
|
import { ExtensionApp } from "./common/vscode/vscode-app";
|
||||||
import { RepositoriesFilterSortStateWithIds } from "./pure/variant-analysis-filter-sort";
|
import { RepositoriesFilterSortStateWithIds } from "./pure/variant-analysis-filter-sort";
|
||||||
|
import { AppMode } from "./common/app";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extension.ts
|
* extension.ts
|
||||||
@@ -623,9 +625,15 @@ async function activateWithInstalledDistribution(
|
|||||||
|
|
||||||
void extLogger.log("Initializing variant analysis manager.");
|
void extLogger.log("Initializing variant analysis manager.");
|
||||||
|
|
||||||
const app = new ExtensionApp(ctx);
|
// We only want to initialize the new db panel when the newQueryRunExperience is enabled
|
||||||
const dbModule = await initializeDbModule(app);
|
let dbModule;
|
||||||
ctx.subscriptions.push(dbModule);
|
if (isCanary() && isNewQueryRunExperienceEnabled()) {
|
||||||
|
const app = new ExtensionApp(ctx);
|
||||||
|
if (app.mode === AppMode.Development) {
|
||||||
|
dbModule = await initializeDbModule(app);
|
||||||
|
ctx.subscriptions.push(dbModule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const variantAnalysisStorageDir = join(
|
const variantAnalysisStorageDir = join(
|
||||||
ctx.globalStorageUri.fsPath,
|
ctx.globalStorageUri.fsPath,
|
||||||
@@ -636,12 +644,13 @@ async function activateWithInstalledDistribution(
|
|||||||
cliServer,
|
cliServer,
|
||||||
extLogger,
|
extLogger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const variantAnalysisManager = new VariantAnalysisManager(
|
const variantAnalysisManager = new VariantAnalysisManager(
|
||||||
ctx,
|
ctx,
|
||||||
cliServer,
|
cliServer,
|
||||||
variantAnalysisStorageDir,
|
variantAnalysisStorageDir,
|
||||||
variantAnalysisResultsManager,
|
variantAnalysisResultsManager,
|
||||||
dbModule.dbManager,
|
dbModule ? dbModule.dbManager : undefined, // the dbModule is only needed when the newQueryRunExperience is enabled
|
||||||
);
|
);
|
||||||
ctx.subscriptions.push(variantAnalysisManager);
|
ctx.subscriptions.push(variantAnalysisManager);
|
||||||
ctx.subscriptions.push(variantAnalysisResultsManager);
|
ctx.subscriptions.push(variantAnalysisResultsManager);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export class VariantAnalysisManager
|
|||||||
private readonly cliServer: CodeQLCliServer,
|
private readonly cliServer: CodeQLCliServer,
|
||||||
private readonly storagePath: string,
|
private readonly storagePath: string,
|
||||||
private readonly variantAnalysisResultsManager: VariantAnalysisResultsManager,
|
private readonly variantAnalysisResultsManager: VariantAnalysisResultsManager,
|
||||||
private readonly dbManager: DbManager,
|
private readonly dbManager?: DbManager, // the dbManager is only needed when the newQueryRunExperience is enabled
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.variantAnalysisMonitor = this.push(
|
this.variantAnalysisMonitor = this.push(
|
||||||
|
|||||||
Reference in New Issue
Block a user