mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fix for history reload upon target change and filter out unsupported … (#13205)
* fix for history reload upon target change and filter out unsupported asmt messages
This commit is contained in:
@@ -121,9 +121,9 @@ export class AssessmentResultGrid implements vscode.Disposable {
|
||||
|
||||
public async displayResult(asmtResult: azdata.SqlAssessmentResult, method: AssessmentType) {
|
||||
this.asmtType = method;
|
||||
this.dataItems = asmtResult.items;
|
||||
this.dataItems = this.filterOutNotSupportedKind(asmtResult.items);
|
||||
await this.table.updateProperties({
|
||||
'data': asmtResult.items.map(item => this.convertToDataView(item))
|
||||
'data': this.dataItems.map(item => this.convertToDataView(item))
|
||||
});
|
||||
this.rootContainer.setLayout({
|
||||
flexFlow: 'column',
|
||||
@@ -145,20 +145,34 @@ export class AssessmentResultGrid implements vscode.Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
public async appendResult(asmtResult: azdata.SqlAssessmentResult): Promise<void> {
|
||||
if (this.dataItems) {
|
||||
this.dataItems.push(...asmtResult.items);
|
||||
// we need to filter out warnings and error results since we don't have an appropriate way of displaying such messages.
|
||||
// have to redone this once required functionality will be added to the core.
|
||||
private filterOutNotSupportedKind(items: azdata.SqlAssessmentResultItem[]): azdata.SqlAssessmentResultItem[] {
|
||||
if (this.asmtType === AssessmentType.AvailableRules) {
|
||||
return items;
|
||||
}
|
||||
this.table.appendData(asmtResult.items.map(item => this.convertToDataView(item)));
|
||||
|
||||
return items.filter(i => i.kind === azdata.sqlAssessment.SqlAssessmentResultItemKind.RealResult);
|
||||
}
|
||||
|
||||
public async appendResult(asmtResult: azdata.SqlAssessmentResult): Promise<void> {
|
||||
let filteredValues = this.filterOutNotSupportedKind(asmtResult.items);
|
||||
if (this.dataItems) {
|
||||
this.dataItems.push(...filteredValues);
|
||||
}
|
||||
this.table.appendData(filteredValues.map(item => this.convertToDataView(item)));
|
||||
}
|
||||
|
||||
private async showDetails(rowNumber: number) {
|
||||
const selectedRowValues = this.table.data[rowNumber];
|
||||
const asmtResultItem = this.dataItems.find(item =>
|
||||
item.targetName === selectedRowValues[this.targetColOrder]
|
||||
&& item.checkId === selectedRowValues[this.checkIdColOrder]
|
||||
&& item.message === selectedRowValues[this.messageColOrder]
|
||||
);
|
||||
const asmtResultItem = this.asmtType === AssessmentType.InvokeAssessment
|
||||
? this.dataItems.find(item =>
|
||||
item.targetName === selectedRowValues[this.targetColOrder]
|
||||
&& item.checkId === selectedRowValues[this.checkIdColOrder]
|
||||
&& item.message === selectedRowValues[this.messageColOrder])
|
||||
: this.dataItems.find(item =>
|
||||
item.targetName === selectedRowValues[this.targetColOrder]
|
||||
&& item.checkId === selectedRowValues[this.checkIdColOrder]);
|
||||
|
||||
if (!asmtResultItem) {
|
||||
return;
|
||||
|
||||
@@ -32,7 +32,7 @@ export class AssessmentEngine {
|
||||
private connectionUri: string = '';
|
||||
private connectionProfile!: azdata.connection.ConnectionProfile;
|
||||
private lastInvokedResults!: SqlAssessmentResultInfo;
|
||||
private historicalRecords!: SqlAssessmentRecord[];
|
||||
private historicalRecords!: SqlAssessmentRecord[] | undefined;
|
||||
|
||||
|
||||
constructor(service: mssql.ISqlAssessmentService) {
|
||||
@@ -56,6 +56,7 @@ export class AssessmentEngine {
|
||||
public async initialize(connectionId: string) {
|
||||
this.connectionUri = await azdata.connection.getUriForConnection(connectionId);
|
||||
this.connectionProfile = await azdata.connection.getCurrentConnection();
|
||||
this.historicalRecords = undefined;
|
||||
}
|
||||
|
||||
public async performAssessment(asmtType: AssessmentType, onResult: OnResultCallback): Promise<void> {
|
||||
@@ -99,7 +100,7 @@ export class AssessmentEngine {
|
||||
await this.loadHistory();
|
||||
}
|
||||
|
||||
return this.historicalRecords;
|
||||
return this.historicalRecords ?? [];
|
||||
}
|
||||
|
||||
private async loadHistory(): Promise<void> {
|
||||
|
||||
@@ -31,7 +31,6 @@ export default class MainController {
|
||||
}
|
||||
|
||||
public async activate(): Promise<boolean> {
|
||||
|
||||
this.sqlAssessment = ((await vscode.extensions.getExtension(mssql.extension.name)?.activate() as mssql.IExtension)).sqlAssessment;
|
||||
this.engine = new AssessmentEngine(this.sqlAssessment);
|
||||
this.registerModelViewProvider();
|
||||
|
||||
Reference in New Issue
Block a user