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 dbf36250cd0a88f69575ee4469ff097c25fff381 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Jul 2022 11:41:26 +0000 Subject: [PATCH 2/2] Bump moment from 2.24.0 to 2.29.4 Bumps [moment](https://github.com/moment/moment) from 2.24.0 to 2.29.4. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.24.0...2.29.4) --- updated-dependencies: - dependency-name: moment dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cd1b31f..3a46525 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@mapbox/mapbox-sdk": "^0.6.0", "axios": "^0.21.1", "config": "^3.2.2", - "moment": "~2.24.0", + "moment": "~2.29.4", "mongodb": "~2.2.24", "path": "^0.12.7", "request": "^2.88.0" diff --git a/yarn.lock b/yarn.lock index 04590ef..983d875 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5066,10 +5066,10 @@ mkdirp@0.x, mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "^1.2.5" -moment@^2.19.3, moment@~2.24.0: - version "2.24.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" - integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== +moment@^2.19.3, moment@~2.29.4: + version "2.29.4" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" + integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== mongodb-core@2.1.20: version "2.1.20"