mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 09:59:47 -05:00
Fixes for sql db projects dashboard (#15100)
* Fix ID assignment for sql db projects dashboard * Update with new fixes * Fix tests * Fix test
This commit is contained in:
@@ -32,7 +32,7 @@ import { DatabaseReferenceTreeItem } from '../models/tree/databaseReferencesTree
|
||||
import { CreateProjectFromDatabaseDialog } from '../dialogs/createProjectFromDatabaseDialog';
|
||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||
import { IconPathHelper } from '../common/iconHelper';
|
||||
import { DashboardData, Status } from '../models/dashboardData/dashboardData';
|
||||
import { DashboardData, PublishData, Status } from '../models/dashboardData/dashboardData';
|
||||
|
||||
const maxTableLength = 10;
|
||||
|
||||
@@ -43,7 +43,7 @@ export class ProjectsController {
|
||||
private netCoreTool: NetCoreTool;
|
||||
private buildHelper: BuildHelper;
|
||||
private buildInfo: DashboardData[] = [];
|
||||
private deployInfo: DashboardData[] = [];
|
||||
private publishInfo: PublishData[] = [];
|
||||
|
||||
projFileWatchers = new Map<string, vscode.FileSystemWatcher>();
|
||||
|
||||
@@ -52,18 +52,17 @@ export class ProjectsController {
|
||||
this.buildHelper = new BuildHelper();
|
||||
}
|
||||
|
||||
public getDashboardDeployData(projectFile: string): (string | dataworkspace.IconCellValue)[][] {
|
||||
public getDashboardPublishData(projectFile: string): (string | dataworkspace.IconCellValue)[][] {
|
||||
const infoRows: (string | dataworkspace.IconCellValue)[][] = [];
|
||||
let count = 0;
|
||||
|
||||
for (let i = this.deployInfo.length - 1; i >= 0; i--) {
|
||||
if (this.deployInfo[i].projectFile === projectFile) {
|
||||
for (let i = this.publishInfo.length - 1; i >= 0; i--) {
|
||||
if (this.publishInfo[i].projectFile === projectFile) {
|
||||
let icon: azdata.IconPath;
|
||||
let text: string;
|
||||
if (this.deployInfo[i].status === Status.success) {
|
||||
if (this.publishInfo[i].status === Status.success) {
|
||||
icon = IconPathHelper.success;
|
||||
text = constants.Success;
|
||||
} else if (this.deployInfo[i].status === Status.failed) {
|
||||
} else if (this.publishInfo[i].status === Status.failed) {
|
||||
icon = IconPathHelper.error;
|
||||
text = constants.Failed;
|
||||
} else {
|
||||
@@ -71,13 +70,13 @@ export class ProjectsController {
|
||||
text = constants.InProgress;
|
||||
}
|
||||
|
||||
let infoRow: (string | dataworkspace.IconCellValue)[] = [count.toString(),
|
||||
{ text: text, icon: icon },
|
||||
this.deployInfo[i].target,
|
||||
this.deployInfo[i].timeToCompleteAction,
|
||||
this.deployInfo[i].startDate];
|
||||
let infoRow: (string | dataworkspace.IconCellValue)[] = [{ text: text, icon: icon },
|
||||
this.publishInfo[i].startDate,
|
||||
this.publishInfo[i].timeToCompleteAction,
|
||||
this.publishInfo[i].target,
|
||||
this.publishInfo[i].targetServer,
|
||||
this.publishInfo[i].targetDatabase];
|
||||
infoRows.push(infoRow);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +85,6 @@ export class ProjectsController {
|
||||
|
||||
public getDashboardBuildData(projectFile: string): (string | dataworkspace.IconCellValue)[][] {
|
||||
const infoRows: (string | dataworkspace.IconCellValue)[][] = [];
|
||||
let count = 0;
|
||||
|
||||
for (let i = this.buildInfo.length - 1; i >= 0; i--) {
|
||||
if (this.buildInfo[i].projectFile === projectFile) {
|
||||
@@ -103,13 +101,11 @@ export class ProjectsController {
|
||||
text = constants.InProgress;
|
||||
}
|
||||
|
||||
let infoRow: (string | dataworkspace.IconCellValue)[] = [count.toString(),
|
||||
{ text: text, icon: icon },
|
||||
this.buildInfo[i].target,
|
||||
let infoRow: (string | dataworkspace.IconCellValue)[] = [{ text: text, icon: icon },
|
||||
this.buildInfo[i].startDate,
|
||||
this.buildInfo[i].timeToCompleteAction,
|
||||
this.buildInfo[i].startDate];
|
||||
this.buildInfo[i].target];
|
||||
infoRows.push(infoRow);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,13 +274,13 @@ export class ProjectsController {
|
||||
telemetryProps.profileUsed = (settings.profileUsed ?? false).toString();
|
||||
const currentDate = new Date();
|
||||
const actionStartTime = currentDate.getTime();
|
||||
const currentDeployTimeInfo = `${currentDate.toLocaleDateString()} ${constants.at} ${currentDate.toLocaleTimeString()}`;
|
||||
const currentPublishTimeInfo = `${currentDate.toLocaleDateString()} ${constants.at} ${currentDate.toLocaleTimeString()}`;
|
||||
|
||||
let deployInfoNew = new DashboardData(project.projectFilePath, Status.inProgress, project.getProjectTargetVersion(), currentDeployTimeInfo);
|
||||
this.deployInfo.push(deployInfoNew);
|
||||
let publishInfoNew = new PublishData(project.projectFilePath, Status.inProgress, project.getProjectTargetVersion(), currentPublishTimeInfo, settings.databaseName, settings.serverName);
|
||||
this.publishInfo.push(publishInfoNew);
|
||||
|
||||
if (this.deployInfo.length - 1 === maxTableLength) {
|
||||
this.deployInfo.shift(); // Remove the first element to maintain the length
|
||||
if (this.publishInfo.length - 1 === maxTableLength) {
|
||||
this.publishInfo.shift(); // Remove the first element to maintain the length
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -298,29 +294,29 @@ export class ProjectsController {
|
||||
}
|
||||
} catch (err) {
|
||||
const actionEndTime = new Date().getTime();
|
||||
const timeToFailureDeploy = actionEndTime - actionStartTime;
|
||||
telemetryProps.actionDuration = timeToFailureDeploy.toString();
|
||||
const timeToFailurePublish = actionEndTime - actionStartTime;
|
||||
telemetryProps.actionDuration = timeToFailurePublish.toString();
|
||||
telemetryProps.totalDuration = (actionEndTime - buildStartTime).toString();
|
||||
|
||||
TelemetryReporter.createErrorEvent(TelemetryViews.ProjectController, TelemetryActions.publishProject)
|
||||
.withAdditionalProperties(telemetryProps)
|
||||
.send();
|
||||
|
||||
const currentDeployIndex = this.deployInfo.findIndex(d => d.startDate === currentDeployTimeInfo);
|
||||
this.deployInfo[currentDeployIndex].status = Status.failed;
|
||||
this.deployInfo[currentDeployIndex].timeToCompleteAction = utils.timeConversion(timeToFailureDeploy);
|
||||
const currentPublishIndex = this.publishInfo.findIndex(d => d.startDate === currentPublishTimeInfo);
|
||||
this.publishInfo[currentPublishIndex].status = Status.failed;
|
||||
this.publishInfo[currentPublishIndex].timeToCompleteAction = utils.timeConversion(timeToFailurePublish);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
const actionEndTime = new Date().getTime();
|
||||
const timeToDeploy = actionEndTime - actionStartTime;
|
||||
telemetryProps.actionDuration = timeToDeploy.toString();
|
||||
const timeToPublish = actionEndTime - actionStartTime;
|
||||
telemetryProps.actionDuration = timeToPublish.toString();
|
||||
telemetryProps.totalDuration = (actionEndTime - buildStartTime).toString();
|
||||
|
||||
const currentDeployIndex = this.deployInfo.findIndex(d => d.startDate === currentDeployTimeInfo);
|
||||
this.deployInfo[currentDeployIndex].status = result.success ? Status.success : Status.failed;
|
||||
this.deployInfo[currentDeployIndex].timeToCompleteAction = utils.timeConversion(timeToDeploy);
|
||||
const currentPublishIndex = this.publishInfo.findIndex(d => d.startDate === currentPublishTimeInfo);
|
||||
this.publishInfo[currentPublishIndex].status = result.success ? Status.success : Status.failed;
|
||||
this.publishInfo[currentPublishIndex].timeToCompleteAction = utils.timeConversion(timeToPublish);
|
||||
|
||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishProject)
|
||||
.withAdditionalProperties(telemetryProps)
|
||||
|
||||
Reference in New Issue
Block a user