limit the data size for chart rendering (#14949)

* limit the rows feed to charts

* add telemetry and option to hide

* fix typo

* updates

* comments

* notebook fix
This commit is contained in:
Alan Ren
2021-04-02 19:36:10 -07:00
committed by GitHub
parent 13ad4c9497
commit c2d2cf5a82
11 changed files with 151 additions and 37 deletions

View File

@@ -20,6 +20,9 @@ import { getErrorMessage } from 'vs/base/common/errors';
import { SaveFormat } from 'sql/workbench/services/query/common/resultSerializer';
import { IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
import { IEncodingSupport } from 'vs/workbench/common/editor';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { getChartMaxRowCount, notifyMaxRowCountExceeded } from 'sql/workbench/contrib/charts/browser/utils';
export interface IGridActionContext {
gridDataProvider: IGridDataProvider;
@@ -167,7 +170,11 @@ export class ChartDataAction extends Action {
constructor(
@IEditorService private editorService: IEditorService,
@IExtensionRecommendationsService private readonly extensionTipsService: IExtensionRecommendationsService
@IExtensionRecommendationsService private readonly extensionTipsService: IExtensionRecommendationsService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStorageService private readonly storageService: IStorageService,
@INotificationService private readonly notificationService: INotificationService,
@IAdsTelemetryService private readonly adsTelemetryService: IAdsTelemetryService
) {
super(ChartDataAction.ID, ChartDataAction.LABEL, ChartDataAction.ICON);
}
@@ -175,7 +182,15 @@ export class ChartDataAction extends Action {
public run(context: IGridActionContext): Promise<boolean> {
// show the visualizer extension recommendation notification
this.extensionTipsService.promptRecommendedExtensionsByScenario(Constants.visualizerExtensions);
const maxRowCount = getChartMaxRowCount(this.configurationService);
const rowCount = context.table.getData().getLength();
const maxRowCountExceeded = rowCount > maxRowCount;
if (maxRowCountExceeded) {
notifyMaxRowCountExceeded(this.storageService, this.notificationService, this.configurationService);
}
this.adsTelemetryService.createActionEvent(TelemetryKeys.TelemetryView.ResultsPanel, TelemetryKeys.TelemetryAction.ShowChart).withAdditionalProperties(
{ [TelemetryKeys.TelemetryPropertyName.ChartMaxRowCountExceeded]: maxRowCountExceeded }
).send();
const activeEditor = this.editorService.activeEditorPane as QueryEditor;
activeEditor.chart({ batchId: context.batchId, resultId: context.resultId });
return Promise.resolve(true);

View File

@@ -383,7 +383,7 @@ export abstract class GridTableBase<T> extends Disposable implements IView {
@IInstantiationService protected readonly instantiationService: IInstantiationService,
@IEditorService private readonly editorService: IEditorService,
@IUntitledTextEditorService private readonly untitledEditorService: IUntitledTextEditorService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
@IQueryModelService private readonly queryModelService: IQueryModelService,
@IThemeService private readonly themeService: IThemeService
) {