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 { App, AppMode } from "../common/app";
|
||||
import { isCanary, isNewQueryRunExperienceEnabled } from "../config";
|
||||
import { App } from "../common/app";
|
||||
import { extLogger } from "../common";
|
||||
import { DisposableObject } from "../pure/disposable-object";
|
||||
import { DbConfigStore } from "./config/db-config-store";
|
||||
@@ -19,18 +18,7 @@ export class DbModule extends DisposableObject {
|
||||
this.dbManager = new DbManager(app, this.dbConfigStore);
|
||||
}
|
||||
|
||||
public async initialize(app: App): 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;
|
||||
}
|
||||
|
||||
public async initialize(): Promise<void> {
|
||||
void extLogger.log("Initializing database module");
|
||||
|
||||
await this.dbConfigStore.initialize();
|
||||
@@ -49,6 +37,6 @@ export class DbModule extends DisposableObject {
|
||||
|
||||
export async function initializeDbModule(app: App): Promise<DbModule> {
|
||||
const dbModule = new DbModule(app);
|
||||
await dbModule.initialize(app);
|
||||
await dbModule.initialize();
|
||||
return dbModule;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
CliConfigListener,
|
||||
DistributionConfigListener,
|
||||
isCanary,
|
||||
isNewQueryRunExperienceEnabled,
|
||||
isVariantAnalysisLiveResultsEnabled,
|
||||
joinOrderWarningThreshold,
|
||||
MAX_QUERIES,
|
||||
@@ -138,6 +139,7 @@ import { VariantAnalysisResultsManager } from "./remote-queries/variant-analysis
|
||||
import { initializeDbModule } from "./databases/db-module";
|
||||
import { ExtensionApp } from "./common/vscode/vscode-app";
|
||||
import { RepositoriesFilterSortStateWithIds } from "./pure/variant-analysis-filter-sort";
|
||||
import { AppMode } from "./common/app";
|
||||
|
||||
/**
|
||||
* extension.ts
|
||||
@@ -623,9 +625,15 @@ async function activateWithInstalledDistribution(
|
||||
|
||||
void extLogger.log("Initializing variant analysis manager.");
|
||||
|
||||
const app = new ExtensionApp(ctx);
|
||||
const dbModule = await initializeDbModule(app);
|
||||
ctx.subscriptions.push(dbModule);
|
||||
// We only want to initialize the new db panel when the newQueryRunExperience is enabled
|
||||
let 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(
|
||||
ctx.globalStorageUri.fsPath,
|
||||
@@ -636,12 +644,13 @@ async function activateWithInstalledDistribution(
|
||||
cliServer,
|
||||
extLogger,
|
||||
);
|
||||
|
||||
const variantAnalysisManager = new VariantAnalysisManager(
|
||||
ctx,
|
||||
cliServer,
|
||||
variantAnalysisStorageDir,
|
||||
variantAnalysisResultsManager,
|
||||
dbModule.dbManager,
|
||||
dbModule ? dbModule.dbManager : undefined, // the dbModule is only needed when the newQueryRunExperience is enabled
|
||||
);
|
||||
ctx.subscriptions.push(variantAnalysisManager);
|
||||
ctx.subscriptions.push(variantAnalysisResultsManager);
|
||||
|
||||
@@ -101,7 +101,7 @@ export class VariantAnalysisManager
|
||||
private readonly cliServer: CodeQLCliServer,
|
||||
private readonly storagePath: string,
|
||||
private readonly variantAnalysisResultsManager: VariantAnalysisResultsManager,
|
||||
private readonly dbManager: DbManager,
|
||||
private readonly dbManager?: DbManager, // the dbManager is only needed when the newQueryRunExperience is enabled
|
||||
) {
|
||||
super();
|
||||
this.variantAnalysisMonitor = this.push(
|
||||
|
||||
Reference in New Issue
Block a user