Skip to content

Commit

Permalink
Removing DataSet/BatchSet Promise (#592)
Browse files Browse the repository at this point in the history
Removing dead code that is no longer being used now that we have the websocket implementation. As far as I can tell, these web server handlers are no longer being called from the preview pane and since they were the only things that hinged on the dataset/batchset promise, we should be able to safely remove these.
  • Loading branch information
benrr101 authored Jan 10, 2017
1 parent 7b57183 commit 82ba079
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 90 deletions.
13 changes: 0 additions & 13 deletions src/controllers/QueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export default class QueryRunner {
private _uri: string;
private _title: string;
private _resultLineOffset: number;
private _batchSetsPromise: Promise<BatchSummary[]>;
public eventEmitter: EventEmitter = new EventEmitter();
public dataResolveReject;

// CONSTRUCTOR /////////////////////////////////////////////////////////

Expand Down Expand Up @@ -80,10 +78,6 @@ export default class QueryRunner {
this._title = title;
}

getBatchSets(): Promise<BatchSummary[]> {
return this._batchSetsPromise;
}

get batchSets(): BatchSummary[] {
return this._batchSets;
}
Expand Down Expand Up @@ -117,10 +111,6 @@ export default class QueryRunner {
this._isExecuting = true;
this._statusView.executingQuery(this.uri);

self._batchSetsPromise = new Promise<BatchSummary[]>((resolve, reject) => {
self.dataResolveReject = {resolve: resolve, reject: reject};
});

return this._client.sendRequest(QueryExecuteRequest.type, queryDetails).then(result => {
self.eventEmitter.emit('start');
if (result.messages) { // Show informational messages if there was no query to execute
Expand All @@ -136,7 +126,6 @@ export default class QueryRunner {
executionEnd: undefined,
executionStart: undefined
}];
self.dataResolveReject.resolve();
this.eventEmitter.emit('batchStart', self._batchSets[0]);
this.eventEmitter.emit('batchComplete', self._batchSets[0]);
} else {
Expand Down Expand Up @@ -172,7 +161,6 @@ export default class QueryRunner {
executionEnd: undefined,
executionStart: undefined
}];
this.dataResolveReject.resolve(this.batchSets);
this.eventEmitter.emit('complete');
return;
}
Expand All @@ -185,7 +173,6 @@ export default class QueryRunner {
}
});
this._statusView.executedQuery(this.uri);
this.dataResolveReject.resolve(this.batchSets);
this.eventEmitter.emit('complete');
}

Expand Down
63 changes: 0 additions & 63 deletions src/models/SqlOutputContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,69 +90,6 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
);
});

// add http handler for '/resultsetsMeta' - return metadata about columns & rows in multiple resultsets
this._service.addHandler(Interfaces.ContentType.ResultsetsMeta, (req, res): void => {
let tempBatchSets: Interfaces.IGridBatchMetaData[] = [];
let uri: string = req.query.uri;
if (self._queryResultsMap.has(uri)) {
self._queryResultsMap.get(uri).queryRunner.getBatchSets().then((batchSets) => {
for (let [batchIndex, batch] of batchSets.entries()) {
let tempBatch: Interfaces.IGridBatchMetaData = {
resultSets: [],
messages: batch.messages,
hasError: batch.hasError,
selection: batch.selection,
startTime: batch.executionStart,
endTime: batch.executionEnd,
totalTime: batch.executionElapsed
};
for (let [resultIndex, result] of batch.resultSetSummaries.entries()) {
let uriFormat = '/{0}?batchId={1}&resultId={2}&uri={3}';
let encodedUri = encodeURIComponent(uri);

tempBatch.resultSets.push( <Interfaces.IGridResultSet> {
columns: result.columnInfo,
rowsUri: Utils.formatString(uriFormat, Constants.outputContentTypeRows, batchIndex, resultIndex, encodedUri),
numberOfRows: result.rowCount
});
}
tempBatchSets.push(tempBatch);
}
let json = JSON.stringify(tempBatchSets);
res.send(json);
});
} else {
// did not find query (most likely expired)
let tempBatch: Interfaces.IGridBatchMetaData = {
resultSets: undefined,
messages: [{
time: undefined,
message: Constants.unfoundResult
}],
hasError: undefined,
selection: undefined,
startTime: undefined,
endTime: undefined,
totalTime: undefined
};
tempBatchSets.push(tempBatch);
let json = JSON.stringify(tempBatchSets);
res.send(json);
}
});

// add http handler for '/columns' - return column metadata as a JSON string
this._service.addHandler(Interfaces.ContentType.Columns, (req, res): void => {
let resultId = req.query.resultId;
let batchId = req.query.batchId;
let uri: string = req.query.uri;
self._queryResultsMap.get(uri).queryRunner.getBatchSets().then((data) => {
let columnMetadata = data[batchId].resultSetSummaries[resultId].columnInfo;
let json = JSON.stringify(columnMetadata);
res.send(json);
});
});

// add http handler for '/rows' - return rows end-point for a specific resultset
this._service.addHandler(Interfaces.ContentType.Rows, (req, res): void => {
let resultId = req.query.resultId;
Expand Down
14 changes: 0 additions & 14 deletions test/queryRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ suite('Query Runner tests', () => {
});

test('Handles result correctly', () => {
let resolveRan = false;
let result: QueryExecuteCompleteNotificationResult = {
ownerUri: 'uri',
message: undefined,
Expand Down Expand Up @@ -398,13 +397,9 @@ suite('Query Runner tests', () => {

queryRunner.eventEmitter = mockEventEmitter.object;
queryRunner.uri = '';
queryRunner.dataResolveReject = {resolve: () => {
resolveRan = true;
}};
queryRunner.handleResult(result);
testStatusView.verify(x => x.executedQuery(TypeMoq.It.isAnyString()), TypeMoq.Times.once());
mockEventEmitter.verify(x => x.emit('complete'), TypeMoq.Times.once());
assert.equal(resolveRan, true);
});

test('Correctly handles subset', () => {
Expand Down Expand Up @@ -570,9 +565,6 @@ suite('Query Runner tests', () => {
testVscodeWrapper.object
);
queryRunner.uri = testuri;
queryRunner.dataResolveReject = {resolve: () => {
// Needed to handle the result callback
}};
// Call handleResult to ensure column header info is seeded
queryRunner.handleResult(result);
return queryRunner.copyResults(testRange, 0, 0).then(() => {
Expand All @@ -596,9 +588,6 @@ suite('Query Runner tests', () => {
testVscodeWrapper.object
);
queryRunner.uri = testuri;
queryRunner.dataResolveReject = {resolve: () => {
// Needed to handle the result callback
}};
// Call handleResult to ensure column header info is seeded
queryRunner.handleResult(result);

Expand All @@ -624,9 +613,6 @@ suite('Query Runner tests', () => {
testVscodeWrapper.object
);
queryRunner.uri = testuri;
queryRunner.dataResolveReject = {resolve: () => {
// Needed to handle the result callback
}};
// Call handleResult to ensure column header info is seeded
queryRunner.handleResult(result);

Expand Down

0 comments on commit 82ba079

Please sign in to comment.