From 181fad51abbf1cfa6620008e5b74461626097a89 Mon Sep 17 00:00:00 2001 From: Marlene Simondant Date: Thu, 10 Mar 2022 11:05:01 +0100 Subject: [PATCH 1/6] fix : typo in email notification --- src/users/users.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/users/users.service.ts b/src/users/users.service.ts index ce0e954..632c624 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -223,7 +223,7 @@ export class UsersService { const html = await ejs.renderFile(ejsPath, { config, - status: status ? 'accepté' : 'refusée', + status: status ? 'acceptée' : 'refusée', name: structureName, }); this.mailerService.send(userEmail, jsonConfig.subject, html); -- GitLab From 37f05ab6fa5734dc03c36f4cfc401cf653388ac7 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS Date: Thu, 10 Mar 2022 14:13:20 +0100 Subject: [PATCH 2/6] fix(tests): avoid error for structure search test --- src/structures/services/structures-search.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/services/structures-search.service.spec.ts b/src/structures/services/structures-search.service.spec.ts index ed22663..67fd4e9 100644 --- a/src/structures/services/structures-search.service.spec.ts +++ b/src/structures/services/structures-search.service.spec.ts @@ -49,7 +49,7 @@ describe('StructuresSearchService', () => { // wait for the new structures to be indexed before search await service.refreshIndexStructure(); // but we still need to wait the refresh to be done - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 2000)); }); it('should find maisons de la métropole', async () => { -- GitLab From 8a7e46357945d6a18cce3eef8105b1b6a471fbc9 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL Date: Tue, 15 Mar 2022 09:10:28 +0100 Subject: [PATCH 3/6] feat(docker): add name to docker container --- docker-compose.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c35a22a..dfd119c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,8 @@ version: '2' services: service-ram: - image: registry.forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server:dev + image: registry.forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server:dev + container_name: resin-back ports: - ${SERVICE_API_BIND_PORT}:3000 extra_hosts: @@ -35,6 +36,7 @@ services: database-ram: image: bitnami/mongodb:4.2.3 user: root + container_name: resin-db environment: MONGODB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD} MONGODB_USERNAME: ${MONGO_NON_ROOT_USERNAME} @@ -50,7 +52,8 @@ services: mongo-express: image: mongo-express - restart: unless-stopped + restart: unless-stopped + container_name: resin-mongo-express depends_on: - database-ram networks: @@ -67,6 +70,7 @@ services: ghost: image: ghost:latest restart: always + container_name: resin-ghost ports: - ${GHOST_PORT}:2368 environment: @@ -78,11 +82,14 @@ services: database__connection__database: ghost # this url value is just an example, and is likely wrong for your environment! url: http://localhost:${GHOST_PORT} + depends_on: + - ghost-db volumes: - ghost-content:/var/lib/ghost/content ghost-db: image: mysql:5.7 + container_name: resin-ghost-db restart: always environment: MYSQL_ROOT_PASSWORD: ${GHOST_DB_PASSWORD} @@ -92,6 +99,7 @@ services: es01: image: elasticsearch:7.16.2 restart: unless-stopped + container_name: resin-es environment: node.name: es01 cluster.name: es-docker-cluster @@ -108,7 +116,7 @@ services: kib01: image: docker.elastic.co/kibana/kibana:7.6.1 restart: unless-stopped - container_name: kib01 + container_name: resin-kib ports: - ${KIBANA_PORT}:5601 environment: -- GitLab From bd87d2bced66cc8fc0c3272f60892b503d1bb6d9 Mon Sep 17 00:00:00 2001 From: Hugo NOUTS Date: Thu, 17 Mar 2022 14:50:54 +0000 Subject: [PATCH 4/6] feat(findAllFormated Structure): Now return structures who gave consent --- src/structures/services/structures.service.ts | 5 +++-- test/mock/services/structures.mock.service.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index b16568d..dcabdb6 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -222,6 +222,7 @@ export class StructuresService { ): Promise { const structures = await this.structureModel.find({ deletedAt: { $exists: false } }).exec(); // Update structures coord and address before sending them + Logger.debug('Find all formated structures, only returning structures who consented to data sharing'); await Promise.all( structures.map((structure: StructureDocument) => { // If structure has no address, add it @@ -239,8 +240,8 @@ export class StructuresService { ); return ( await this.structureModel - .find({ deletedAt: { $exists: false }, accountVerified: true }) - .select('-_id -accountVerified -otherDescription') + .find({ deletedAt: { $exists: false }, accountVerified: true, $where: 'this.dataShareConsentDate != null' }) + .select('-_id -accountVerified -otherDescription -dataShareConsentDate') .exec() ).map((structure) => { // If structure has temp email, hide it diff --git a/test/mock/services/structures.mock.service.ts b/test/mock/services/structures.mock.service.ts index d758744..8507700 100644 --- a/test/mock/services/structures.mock.service.ts +++ b/test/mock/services/structures.mock.service.ts @@ -708,6 +708,7 @@ export class StructuresServiceMock { nbScanners: 1, freeWorkShop: false, accountVerified: true, + dataShareConsentDate: '2022-03-01T09:00:00.000Z', createdAt: '2021-05-06T09:42:38.000Z', updatedAt: '2021-05-06T09:42:50.000Z', __v: 0, @@ -782,6 +783,7 @@ export class StructuresServiceMock { nbScanners: 1, freeWorkShop: false, accountVerified: true, + dataShareConsentDate: '2022-03-01T09:00:00.000Z', createdAt: '2021-05-06T09:42:38.000Z', updatedAt: '2021-05-06T09:42:50.000Z', __v: 0, -- GitLab From c02c650ef0c17409153a1416688537c0a3d84d79 Mon Sep 17 00:00:00 2001 From: Hugo NOUTS Date: Fri, 18 Mar 2022 09:28:55 +0000 Subject: [PATCH 5/6] fix(structures): Photon-ban and photon-bal results are now returned together --- src/structures/services/structures.service.ts | 140 +++++++++++++----- 1 file changed, 100 insertions(+), 40 deletions(-) diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index dcabdb6..00835d1 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -346,23 +346,57 @@ export class StructuresService { */ private getStructurePosition(structure: Structure): Promise { return new Promise((resolve, reject) => { - this.getCoord(structure.address.numero, structure.address.street, structure.address.commune).subscribe( + this.getCoord(structure.address.numero, structure.address.street, structure.address.commune, 'photon').subscribe( (res) => { - const address = res.data.features[0]; - if (address && address.geometry) { - structure.coord = address.geometry.coordinates; - } else { - Logger.error( - `No coord found for: ${structure.address.numero} ${structure.address.street} ${structure.address.commune}`, - 'StructureService' - ); - structure.coord = []; - } - resolve(structure); + this.getCoord( + structure.address.numero, + structure.address.street, + structure.address.commune, + 'photon-bal' + ).subscribe((resbal) => { + // check if photon-bal is more precise than photon ban + if (resbal.data.features.length > 0) { + resbal.data.features = resbal.data.features.sort((a, b) => { + return b.properties.housenumber ? 1 : -1; + }); + const address = resbal.data.features[0]; + if (address && address.geometry) { + structure.coord = address.geometry.coordinates; + } else { + Logger.error( + `No coord found for: ${structure.address.numero} ${structure.address.street} ${structure.address.commune}`, + 'StructureService' + ); + structure.coord = []; + } + resolve(structure); + // else pick structure from photonban if it exists or throw error + } else { + if (res.data.features.length > 0) { + const address = res.data.features[0]; + if (address && address.geometry) { + structure.coord = address.geometry.coordinates; + } else { + Logger.error( + `No coord found for: ${structure.address.numero} ${structure.address.street} ${structure.address.commune}`, + 'StructureService' + ); + structure.coord = []; + } + resolve(structure); + } else { + Logger.error( + `No structure found for: ${structure.address.numero} ${structure.address.street} ${structure.address.commune}`, + 'StructureService' + ); + } + } + }); }, (err) => { Logger.error(`Request error: ${err.config.url}`, 'StructureService'); Logger.error(err); + reject(err); } ); }); @@ -383,32 +417,56 @@ export class StructuresService { */ public async searchAddress(data: { searchQuery: string; - }): Promise> { - const req = `https://download.data.grandlyon.com/geocoding/photon/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`; - Logger.debug(`Search request: ${encodeURI(req)}`, 'StructureService'); - return new Promise((resolve, reject) => { - this.httpService - .request({ - url: encodeURI(req), - method: 'GET', - headers: { 'Content-Type': 'application/json' }, - }) - .subscribe( - (reply) => { - Logger.debug(`Search request response length : ${reply.data.features.length}`, 'StructureService'); - reply.data.features = reply.data.features - .filter((doc) => doc.properties.postcode && doc.properties.postcode.match(depRegex)) - .sort((a, b) => { - return b.properties.housenumber ? 1 : -1; - }); - return resolve(reply.data); - }, - (err) => { - Logger.error(`Search - Request error: ${err.config.url}`, 'StructureService'); - Logger.error(err); - } - ); + }): Promise<{ features: { geometry: {}; type: string; properties: {} }[] }> { + const reqBan = `https://download.data.grandlyon.com/geocoding/photon/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`; + + const reqBal = `https://download.data.grandlyon.com/geocoding/photon-bal/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`; + + const requestGroup = (url): Promise<{ features: { geometry: {}; type: string; properties: {} }[] }> => + new Promise((resolve, reject) => { + Logger.debug(`Search request: ${encodeURI(url)}`, 'StructureService'); + return this.httpService + .request({ + url: encodeURI(url), + method: 'GET', + headers: { 'Content-Type': 'application/json' }, + }) + .subscribe( + (reply) => { + Logger.debug(`Search request response length : ${reply.data.features.length}`, 'StructureService'); + reply.data.features = reply.data.features + .filter((doc) => doc.properties.postcode && doc.properties.postcode.match(depRegex)) + .sort((a, b) => { + return b.properties.housenumber ? 1 : -1; + }); + return resolve(reply.data); + }, + (err) => { + Logger.error(`Search - Request error: ${err.config.url}`, 'StructureService'); + Logger.error(err); + } + ); + }); + + const [reqBanRes, reqBalRes] = await Promise.all([requestGroup(reqBan), requestGroup(reqBal)]); + const mergedArray = [...reqBalRes['features'], ...reqBanRes['features']]; + const duplicateFreeArray = _.unionWith(mergedArray, function (a, b) { + return ( + // excludes structures from photon-BAN if they share postcode && street or name && housenumber + // checking for name and street existance asserts that we will not compare 2 undefined fields + a.properties.postcode === b.properties.postcode && + ((a.properties.name && + (a.properties.name === b.properties.name || a.properties.name === b.properties.street)) || + (a.properties.street && + (a.properties.street === b.properties.name || a.properties.street === b.properties.street))) && + (a.properties.housenumber === b.properties.housenumber || + (!a.properties.housenumber && !b.properties.housenumber)) + ); }); + + return { + features: duplicateFreeArray, + }; } /** @@ -447,9 +505,11 @@ export class StructuresService { ); } - public getCoord(numero: string, address: string, zipcode: string): Observable> { - const req = 'https://download.data.grandlyon.com/geocoding/photon/api?q=' + numero + ' ' + address + ' ' + zipcode; - Logger.log(`getCoord - Request : ${req}`, 'StructureService'); + public getCoord(numero: string, address: string, zipcode: string, scope: string): Observable> { + const req = + `https://download.data.grandlyon.com/geocoding/${scope}/api?q=` + numero + ' ' + address + ' ' + zipcode; + Logger.debug('Print getCoord' + req); + return this.httpService.get(encodeURI(req)); } -- GitLab From 51902273bd2f601f1a67fbd7591ae0dacc341256 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL Date: Fri, 18 Mar 2022 10:47:00 +0100 Subject: [PATCH 6/6] chore(release): 1.16.0 --- CHANGELOG.md | 14 ++++++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8591acd..9d3bc67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.16.0](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v1.15.1...v1.16.0) (2022-03-18) + + +### Features + +* **docker:** add name to docker container ([8a7e463](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/8a7e46357945d6a18cce3eef8105b1b6a471fbc9)) +* **findAllFormated Structure:** Now return structures who gave consent ([bd87d2b](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/bd87d2bced66cc8fc0c3272f60892b503d1bb6d9)) + + +### Bug Fixes + +* **structures:** Photon-ban and photon-bal results are now returned together ([c02c650](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/c02c650ef0c17409153a1416688537c0a3d84d79)) +* **tests:** avoid error for structure search test ([37f05ab](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/37f05ab6fa5734dc03c36f4cfc401cf653388ac7)) + ### [1.15.1](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v1.15.0...v1.15.1) (2022-03-08) diff --git a/package-lock.json b/package-lock.json index d8d4732..50a77fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ram_server", - "version": "1.15.1", + "version": "1.16.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 873f4cd..aa80b21 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ram_server", "private": true, - "version": "1.15.1", + "version": "1.16.0", "description": "Nest TypeScript starter repository", "license": "MIT", "scripts": { -- GitLab