From f7c669c3bcf3032d88266d3c7860ac53f3088381 Mon Sep 17 00:00:00 2001 From: Alena Khineika Date: Mon, 18 May 2020 17:46:25 +0200 Subject: [PATCH] fix: playground through ssh connection --- examples/lucas_plant_temp_readings.mongodb | 101 ------------------ package-lock.json | 30 +++--- package.json | 4 +- src/connectionModelType.ts | 1 + src/editors/playgroundController.ts | 4 +- .../editors/playgroundController.test.ts | 2 +- .../language/languageServerController.test.ts | 2 +- 7 files changed, 22 insertions(+), 122 deletions(-) delete mode 100644 examples/lucas_plant_temp_readings.mongodb diff --git a/examples/lucas_plant_temp_readings.mongodb b/examples/lucas_plant_temp_readings.mongodb deleted file mode 100644 index c855b5ba8..000000000 --- a/examples/lucas_plant_temp_readings.mongodb +++ /dev/null @@ -1,101 +0,0 @@ -const foo = db.lucas_plant_temp_readings.findOne(); -/** - * Each document in `lucas_plant_temp_readings` was imported from a .csv: - * - * @example - * ```javascript - * { - * "_id": ObjectId("5e679eb3fa895c4caff53af6"), - * "Date": "2019-07-10", - * "Tag 3 Time": "17:51:42", - * "Tag 3 Temp F": "75.2192947387695", - * "Water Sensor 1 Time": "18:03:13", - * "Water Sensor 1 Temp F": "81.1489730834961", - * "Water Sensor 0 Time": "18:55:26", - * "Water Sensor 0 Temp F": "86.4652744293213", - * "Light Sensor 2 Time": "17:52:53", - * "Light Sensor 2 Temp F": "74.8718040466309" - * } - * ``` - */ - - -/** - * Hydrate each source as embedded documents with Date and Double values - * for each reading. - */ -let HYDRATE = { - $project: { - Date: 1, - // Tag 3 - readings: [ - { - _id: { - sensorName: "Tag 3", - timestamp: { $toDate: { $concat: [ "$Date", "$Tag 3 Time","Z" ] } }, - }, - temperature: { $toDouble: "$Tag 3 Temp F"} - }, - // Water Sensor 1 - { - _id: { - sensorName: "Water Sensor 1", - timestamp: { $toDate: { $concat: [ "$Date", "$Water Sensor 1 Time","Z" ] } }, - }, - temperature: { $toDouble: "$Water Sensor 1 Temp F"} - }, - // Water Sensor 0 - { - _id: { - sensorName: "Water Sensor 0", - timestamp: { $toDate: { $concat: [ "$Date", "$Water Sensor 1 Time","Z" ] } }, - }, - temperature: { $toDouble: "$Water Sensor 1 Temp F"} - }, - // Light Sensor 2 - { - _id: { - sensorName: "Light Sensor 2", - timestamp: { $toDate: { $concat: [ "$Date", "$Light Sensor 2 Time","Z" ] } }, - }, - temperature: { $toDouble: "$Light Sensor 2 Temp F"} - } - ] - } -}; -db.lucas_plant_temp_readings.aggregate([HYDRATE]); - - -/** - * Now I have a super easy to read data frame for temperature in farenheit: - * @example - * ```javascript - * { "_id" : { "sensorName" : "Tag 3", "timestamp" : ISODate("2019-07-10T14:57:26Z") }, "temperature" : 79.8911483764648 } - * { "_id" : { "sensorName" : "Water Sensor 1", "timestamp" : ISODate("2019-07-10T14:45:41Z") }, "temperature" : 77.2473949432373 } - * { "_id" : { "sensorName" : "Water Sensor 0", "timestamp" : ISODate("2019-07-10T14:45:41Z") }, "temperature" : 77.2473949432373 } - * { "_id" : { "sensorName" : "Light Sensor 2", "timestamp" : ISODate("2019-07-10T14:56:57Z") }, "temperature" : 79.3119937896729 } - * ``` - */ -db.lucas_plant_temp_readings.aggregate([ - HYDRATE, - { $unwind: "$readings" }, - { $project: { - _id: "$readings._id", - temperature: "$readings.temperature" - }} -]); - -/** - * I'll save all of these to a readings collection to play around more with. - * My `{sensorName, timestamp}` primary key will make it easy to blend in other data - * from separate .csv's like Lux/Light Level, pH, cat montion sensor detection hit, etc. - */ -db.lucas_plant_temp_readings.aggregate([ - HYDRATE, - { $unwind: "$readings" }, - { $project: { - _id: "$readings._id", - temperature: "$readings.temperature" - }}, - { $merge: { into: "readings", on: "_id", whenMatched: "replace", whenNotMatched: "insert" } } -]); diff --git a/package-lock.json b/package-lock.json index 5ed74eee4..67ce1188e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7119,9 +7119,9 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "is-function": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", - "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz", + "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==" }, "is-glob": { "version": "4.0.1", @@ -9042,16 +9042,16 @@ } }, "mongodb-connection-model": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/mongodb-connection-model/-/mongodb-connection-model-16.0.1.tgz", - "integrity": "sha512-UxXmx7MRxo37DE0ex8Nb51+1Psqlcauto5dlanKwQhlgUTUd9RYK0n9Ju+HSZmvEyZK+sC86k3etTwP1Su1w0g==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-model/-/mongodb-connection-model-16.1.0.tgz", + "integrity": "sha512-f3NmkgYoSXdoYYht70LyOPyrLTkLDfxLuYcnKVp9B7YxaWoueJKP3qwxlCeB9UolV6rMQolvHtYCU+hfSs43bA==", "requires": { "ampersand-model": "^8.0.0", "ampersand-rest-collection": "^6.0.0", "async": "^3.1.0", "debug": "^4.1.1", "lodash": "^4.17.15", - "mongodb": "^3.5.6", + "mongodb": "^3.5.7", "raf": "^3.4.1", "ssh2": "^0.8.7", "storage-mixin": "^3.3.3" @@ -9098,16 +9098,16 @@ } }, "mongodb-data-service": { - "version": "16.6.6", - "resolved": "https://registry.npmjs.org/mongodb-data-service/-/mongodb-data-service-16.6.6.tgz", - "integrity": "sha512-gG+cfQRUH/8DFyPjLBrzS+mQkJy5+Rl99mAVC08m0P0fRWAZq83AILaAIBtKGythW+6YVyQUR3jV3EYX1bY80w==", + "version": "16.7.0", + "resolved": "https://registry.npmjs.org/mongodb-data-service/-/mongodb-data-service-16.7.0.tgz", + "integrity": "sha512-WKlVnHQqTfQ7UgXNlFLplGbdnUYG1e51ks9QMk+E9EoGjy/LeT41GGAdxqBhK5Deb5SeIaCm+lx0dYpvQdoS5A==", "requires": { "async": "^3.2.0", "debug": "^4.1.1", "lodash": "^4.17.15", - "mongodb": "^3.5.6", + "mongodb": "^3.5.7", "mongodb-collection-sample": "^4.5.1", - "mongodb-connection-model": "^16.0.1", + "mongodb-connection-model": "^16.1.0", "mongodb-index-model": "^2.6.1", "mongodb-js-errors": "^0.5.0", "mongodb-ns": "^2.2.0", @@ -11738,9 +11738,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz", - "integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==" + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" }, "querystring": { "version": "0.2.0", diff --git a/package.json b/package.json index 0db9949f8..0626fde20 100644 --- a/package.json +++ b/package.json @@ -618,8 +618,8 @@ "dotenv": "^8.2.0", "encoding": "^0.1.12", "mongodb-cloud-info": "^1.1.2", - "mongodb-connection-model": "^16.0.1", - "mongodb-data-service": "^16.6.6", + "mongodb-connection-model": "^16.1.0", + "mongodb-data-service": "^16.7.0", "mongodb-ns": "^2.2.0", "mongodb-schema": "^8.2.5", "react": "^16.13.1", diff --git a/src/connectionModelType.ts b/src/connectionModelType.ts index 439fdf8f5..0f6c445b7 100644 --- a/src/connectionModelType.ts +++ b/src/connectionModelType.ts @@ -1,5 +1,6 @@ type ConnectionAttributes = { driverUrl: string; + driverUrlWithSsh: string; driverOptions: any; instanceId: string; }; diff --git a/src/editors/playgroundController.ts b/src/editors/playgroundController.ts index a84977b55..d167db270 100644 --- a/src/editors/playgroundController.ts +++ b/src/editors/playgroundController.ts @@ -87,8 +87,8 @@ export default class PlaygroundController { .getActiveConnectionModel() ?.getAttributes({ derived: true }); - if (model && model.driverUrl) { - this._connectionString = model.driverUrl; + if (model && model.driverUrlWithSsh) { + this._connectionString = model.driverUrlWithSsh; this._connectionOptions = model.driverOptions ? model.driverOptions : {}; return this._languageServerController.connectToServiceProvider({ diff --git a/src/test/suite/editors/playgroundController.test.ts b/src/test/suite/editors/playgroundController.test.ts index a7dfe968d..09e0a3020 100644 --- a/src/test/suite/editors/playgroundController.test.ts +++ b/src/test/suite/editors/playgroundController.test.ts @@ -15,7 +15,7 @@ const expect = chai.expect; chai.use(require('chai-as-promised')); const CONNECTION = { - driverUrl: 'mongodb://localhost:27018', + driverUrlWithSsh: 'mongodb://localhost:27018', driverOptions: {} }; diff --git a/src/test/suite/language/languageServerController.test.ts b/src/test/suite/language/languageServerController.test.ts index ae870399d..79b0c9f31 100644 --- a/src/test/suite/language/languageServerController.test.ts +++ b/src/test/suite/language/languageServerController.test.ts @@ -19,7 +19,7 @@ import { TestExtensionContext } from '../stubs'; import { mdbTestExtension } from '../stubbableMdbExtension'; const CONNECTION = { - driverUrl: 'mongodb://localhost:27018', + driverUrlWithSsh: 'mongodb://localhost:27018', driverOptions: {} };