From 406937cebd705855a65a4505e73a1dfe1ff379b2 Mon Sep 17 00:00:00 2001 From: Felipe Vignon Date: Wed, 30 Mar 2022 12:09:55 -0300 Subject: [PATCH 1/2] Developer interview --- src/MongoManager.ts | 13 +++++++++++-- src/__unit-tests__/controller.test.ts | 2 +- src/__unit-tests__/distanceMatrixService.test.ts | 12 +++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/MongoManager.ts b/src/MongoManager.ts index 8f215c3..19e98c3 100644 --- a/src/MongoManager.ts +++ b/src/MongoManager.ts @@ -91,8 +91,17 @@ class MongoManager { ); } - async getLocation(id: string) { - throw new Error("Not implemented"); + async getLocation(id: string): Promise { + console.info("Get location"); + let location: object; + try { + location = await this.database + .collection(LOCATION_UPDATES_COLLECTION_NAME) + .findOne({ _id: id }); + } catch (err) { + console.error(`Error getting location with _id ${id}`, err); + } + return location; } async addLocationUpdate(eta, locationUpdate): Promise { diff --git a/src/__unit-tests__/controller.test.ts b/src/__unit-tests__/controller.test.ts index 7cb3ed2..02acff7 100644 --- a/src/__unit-tests__/controller.test.ts +++ b/src/__unit-tests__/controller.test.ts @@ -9,7 +9,7 @@ import config = require("config"); import mbxMatrix = require("@mapbox/mapbox-sdk/services/matrix"); jest.mock("@mapbox/mapbox-sdk/services/matrix"); -jest.mock("../mongoManager"); +jest.mock("../MongoManager"); jest.mock("../distanceMatrixService"); jest.mock("../twiageApiService"); diff --git a/src/__unit-tests__/distanceMatrixService.test.ts b/src/__unit-tests__/distanceMatrixService.test.ts index 1595ecd..4a3d486 100644 --- a/src/__unit-tests__/distanceMatrixService.test.ts +++ b/src/__unit-tests__/distanceMatrixService.test.ts @@ -7,7 +7,7 @@ import DistanceMatrixService, { import MongoManager from "../MongoManager"; jest.mock("@mapbox/mapbox-sdk/services/matrix"); -jest.mock("../mongoManager"); +jest.mock("../MongoManager"); describe("DistanceMatrixService", () => { describe("constructor", () => { @@ -52,8 +52,14 @@ describe("DistanceMatrixService", () => { const expectedMapboxMatrixData = { body: { code: "Ok", - distances: [[0, 139.9], [49, 0]], - durations: [[0, expectedEtaInSeconds], [25.5, 0]], + distances: [ + [0, 139.9], + [49, 0] + ], + durations: [ + [0, expectedEtaInSeconds], + [25.5, 0] + ], destinations: [ { distance: 2.713771455, name: "", location: [] }, { distance: 1.453423572, name: "", location: [] } From eb86884b4c220126a926de8e672f9fe4b171ad58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Apr 2022 00:05:18 +0000 Subject: [PATCH 2/2] Bump async from 2.6.3 to 2.6.4 Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04590ef..03bf9a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1613,9 +1613,9 @@ async-limiter@~1.0.0: integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== async@^2.0.0: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== dependencies: lodash "^4.17.14" @@ -4803,9 +4803,9 @@ lodash.unescape@4.0.1: integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.8.0: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== lolex@^4.2.0: version "4.2.0"