Skip to content

Commit 5ae28b3

Browse files
fix the issue with start scratchpad
1 parent 05b22ae commit 5ae28b3

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

src/classes/insightsConnection.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class InsightsConnection {
8686
await this.getConfig();
8787
await this.getApiConfig();
8888
await this.getMeta();
89+
await this.startScratchpadSession();
8990
}
9091
});
9192
return this.connected;
@@ -805,6 +806,46 @@ export class InsightsConnection {
805806
}
806807
}
807808

809+
public async startScratchpadSession(): Promise<void> {
810+
if (this.connected && this.connEndpoints) {
811+
const body: ScratchpadRequestBody = {
812+
expression: "",
813+
language: "q",
814+
context: ".",
815+
sampleFn: "first",
816+
sampleSize: 1,
817+
};
818+
const scratchpadURL = new url.URL(
819+
this.connEndpoints.scratchpad.scratchpad,
820+
this.node.details.server,
821+
);
822+
const options = await this.getOptions(
823+
true,
824+
customHeadersJson,
825+
"POST",
826+
scratchpadURL.toString(),
827+
body,
828+
);
829+
830+
if (options === undefined) {
831+
return;
832+
}
833+
834+
notify("REST", MessageKind.DEBUG, {
835+
logger,
836+
params: { url: options.url },
837+
});
838+
839+
return await axios(options).then((_res: any) => {
840+
notify(
841+
`Scratchpad created for connection: ${this.connLabel}.`,
842+
MessageKind.DEBUG,
843+
{ logger },
844+
);
845+
});
846+
}
847+
}
848+
808849
public async getScratchpadQuery(
809850
body: ScratchpadRequestBody,
810851
isPython?: boolean,

src/utils/connLabel.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ export function clearWorkspaceLabels() {
4141
getWorkspaceLabelsConnMap();
4242

4343
if (ext.connLabelList.length === 0) {
44-
notify(
45-
"Cleaning connection mappings for nonexistent labels.",
46-
MessageKind.DEBUG,
47-
{
48-
logger,
49-
telemetry: "Label.Cleanup.NoLabels",
50-
},
51-
);
5244
workspace.getConfiguration().update("kdb.labelsConnectionMap", [], true);
5345
return;
5446
}

0 commit comments

Comments
 (0)