From 32c013a72c6a47613562d526811d82ddcba9e6c1 Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Tue, 19 Feb 2019 15:43:16 -1000 Subject: [PATCH] Add total execution time message for SQL notebooks (#4093) * Display total execution time for sql notebooks * remove handlebatchstart since it was unnecessary --- .../notebook/common/sqlSessionManager.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sql/workbench/services/notebook/common/sqlSessionManager.ts b/src/sql/workbench/services/notebook/common/sqlSessionManager.ts index 31df548932..08ae6abee2 100644 --- a/src/sql/workbench/services/notebook/common/sqlSessionManager.ts +++ b/src/sql/workbench/services/notebook/common/sqlSessionManager.ts @@ -7,6 +7,7 @@ import * as os from 'os'; import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary, IResultMessage } from 'sqlops'; import { localize } from 'vs/nls'; +import * as strings from 'vs/base/common/strings'; import { FutureInternal, ILanguageMagic } from 'sql/parts/notebook/models/modelInterfaces'; import QueryRunner, { EventType } from 'sql/platform/query/common/queryRunner'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; @@ -19,6 +20,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { escape } from 'sql/base/common/strings'; +import { elapsedTimeLabel } from 'sql/parts/query/common/localizedConstants'; import * as notebookUtils from 'sql/parts/notebook/notebookUtils'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -376,20 +378,26 @@ export class SQLFuture extends Disposable implements FutureInternal { // no-op } - public handleMessage(msg: IResultMessage): void { + public handleMessage(msg: IResultMessage | string): void { if (this.ioHandler) { let message; - if (msg.isError) { - message = this.convertToError(msg); - } else { + if (typeof msg === 'string') { message = this.convertToDisplayMessage(msg); } + else { + if (msg.isError) { + message = this.convertToError(msg); + } else { + message = this.convertToDisplayMessage(msg); + } + } this.ioHandler.handle(message); } } public handleBatchEnd(batch: BatchSummary): void { if (this.ioHandler) { + this.handleMessage(strings.format(elapsedTimeLabel, batch.executionElapsed)); for (let resultSet of batch.resultSetSummaries) { let rowCount = resultSet.rowCount > this.configuredMaxRows ? this.configuredMaxRows : resultSet.rowCount; this._queryRunner.getQueryRows(0, rowCount, resultSet.batchId, resultSet.id).then(d => {