Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 208-evenements-affichage
  • 23-a-valider-avec-erwan-check-plus-precis-du-cnfs-id-ainsi-que-des-plages-de-rdv-ouvertes
  • 484-statistiques-requete
  • 50-exception-handling
  • 712-evenements-page-de-saisie
  • V2.5
  • client-476-add-localization-filter
  • dependencies/nestjs
  • dev
  • master
  • openshift-test-deploy
  • pnpm
  • renovate/bitnami-mongodb-4.x
  • renovate/bitnami-mongodb-8.x
  • renovate/devdependencies-(non-major)
  • renovate/elastic-elasticsearch-8.x
  • renovate/elasticsearch-7.x
  • renovate/eslint-9.x
  • renovate/express-5.x
  • renovate/ghcr.io-browserless-chromium-2.x
  • renovate/ghost-5.x
  • renovate/gouvfr-anct-timetable-to-osm-opening-hours-2.x
  • renovate/jest-junit-16.x
  • renovate/luxon-3.x
  • renovate/major-jest-monorepo
  • renovate/major-nest-monorepo
  • renovate/major-typescript-eslint-monorepo
  • renovate/mongo-express-1.x
  • renovate/mysql-9.x
  • renovate/nestjs-schematics-11.x
  • renovate/npm-11.x
  • renovate/tsconfig-paths-4.x
  • send-mail-to-structure-after-orientation
  • tests/users-controllers
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.12.0
  • v1.13.0
  • v1.15.0
  • v1.15.1
  • v1.16.0
  • v1.17.0
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.8.0
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.0-beta1
  • v2.0.0-beta1.1
  • v2.0.0-beta2
  • v2.0.0-beta3
  • v2.0.0-beta4
  • v2.0.0-beta5
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.1.1
  • v2.1.2
  • v2.1.3
  • v2.2.0
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.5.0
  • v3.0.0
  • v3.0.1
  • v3.1.0
  • v3.2.0
  • v3.3.0
  • v3.3.1
  • v3.4.0
  • v3.4.1
  • v3.4.2
  • v3.4.3
  • v4.0.0
  • v4.0.1
  • v4.0.3
88 results

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Select Git revision
  • 208-evenements-affichage
  • 23-a-valider-avec-erwan-check-plus-precis-du-cnfs-id-ainsi-que-des-plages-de-rdv-ouvertes
  • 484-statistiques-requete
  • 50-exception-handling
  • 712-evenements-page-de-saisie
  • V2.5
  • client-476-add-localization-filter
  • dependencies/nestjs
  • dev
  • master
  • openshift-test-deploy
  • pnpm
  • renovate/bitnami-mongodb-4.x
  • renovate/bitnami-mongodb-8.x
  • renovate/devdependencies-(non-major)
  • renovate/elastic-elasticsearch-8.x
  • renovate/elasticsearch-7.x
  • renovate/eslint-9.x
  • renovate/express-5.x
  • renovate/ghcr.io-browserless-chromium-2.x
  • renovate/ghost-5.x
  • renovate/gouvfr-anct-timetable-to-osm-opening-hours-2.x
  • renovate/jest-junit-16.x
  • renovate/luxon-3.x
  • renovate/major-jest-monorepo
  • renovate/major-nest-monorepo
  • renovate/major-typescript-eslint-monorepo
  • renovate/mongo-express-1.x
  • renovate/mysql-9.x
  • renovate/nestjs-schematics-11.x
  • renovate/npm-11.x
  • renovate/tsconfig-paths-4.x
  • send-mail-to-structure-after-orientation
  • tests/users-controllers
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.12.0
  • v1.13.0
  • v1.15.0
  • v1.15.1
  • v1.16.0
  • v1.17.0
  • v1.2.0
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.8.0
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.0-beta1
  • v2.0.0-beta1.1
  • v2.0.0-beta2
  • v2.0.0-beta3
  • v2.0.0-beta4
  • v2.0.0-beta5
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.1.1
  • v2.1.2
  • v2.1.3
  • v2.2.0
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.5.0
  • v3.0.0
  • v3.0.1
  • v3.1.0
  • v3.2.0
  • v3.3.0
  • v3.3.1
  • v3.4.0
  • v3.4.1
  • v3.4.2
  • v3.4.3
  • v4.0.0
  • v4.0.1
  • v4.0.3
88 results
Show changes
Commits on Source (22)
Showing
with 251 additions and 681 deletions
......@@ -2,6 +2,28 @@
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.
## [2.0.0-beta5](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta4...v2.0.0-beta5) (2022-11-23)
### Features
* delete personal offer when quitting structure ([5d96b02](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/5d96b02cb75b10a61b3ddd93f9a1867f9ea76422))
* **orientation:** Add preferredLanguage in onlineMediation ([550bfd2](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/550bfd248d9502aff43540c6f17b470706babcf0))
* personal offers section in profile ([e232021](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/e23202123c483d2b4cddd59435d131d7cf6aef51))
* Remove equipmentsServices from referential ([f5dcd8f](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/f5dcd8f61f138bbf910a124a6748db67440a70ff))
* **structure:** add protection on empty equipments ([13d54d9](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/13d54d94b1af526f11580c0328c7d5bb2b100daa))
* **structure:** change arrondissement ([9df494a](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/9df494ad747b23387715cf63007da430a8c5f875))
* update docker-compose path ([950a916](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/950a916edc4deca7b253272243e43bbf0d2ac347))
### Bug Fixes
* **aptic:** structure categories creation order ([8edd59e](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/8edd59e706713b50b922d1a02037c2a71bd14181))
* return types on addOwner ([8a96551](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/8a9655154f21d8dd4c7e93f4c4f569981f2579be))
* **structure-search:** structure type field index was wrong ([4749aec](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/4749aecd29fefa771795c1dc88343e536ddc73f4))
* **TCL:** format update from open data endpoint ([0dcda95](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/0dcda950d4e3dd79e709890a434341a198506ecb))
* update address ([973fc26](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/973fc26bdcc21a77aa980f71b71e12f2f97dff80))
## [2.0.0-beta4](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta3...v2.0.0-beta4) (2022-10-31)
......
......@@ -2,7 +2,7 @@ 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/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server:dev
container_name: resin-back
ports:
- ${SERVICE_API_BIND_PORT}:3000
......
This diff is collapsed.
{
"name": "ram_server",
"private": true,
"version": "2.0.0-beta4",
"version": "2.0.0-beta5",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
......@@ -81,7 +81,7 @@
"eslint-plugin-prettier": "^4.0.0",
"jest": "^26.6.3",
"jest-junit": "^14.0.0",
"nodemon": "^2.0.6",
"nodemon": "^2.0.20",
"prettier": "^2.1.2",
"supertest": "^6.0.0",
"ts-jest": "^26.4.3",
......
......@@ -365,24 +365,5 @@ module.exports = {
theme: 'Public',
id: 'publicOthers',
},
{
modules: [
{
id: 'donDeMateriels',
name: 'Prêt / don de matériels',
},
{
id: 'reconditionnementsDeMateriel',
name: 'Reconditionnements de matériel',
},
{
id: 'accesLivresInformatiques',
name: 'Accès à des revues ou livres informatiques et numériques',
},
],
name: 'Autres services',
theme: 'Matériel et wifi',
id: 'equipmentsServices',
},
],
};
......@@ -53,7 +53,6 @@ module.exports = {
],
selfServiceMaterial: ['wifiEnAccesLibre', 'computer', 'printer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young', 'family'],
......@@ -156,7 +155,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young'],
......@@ -180,7 +178,6 @@ module.exports = {
exceptionalClosures: '',
publicsAccompaniment: [],
autresAccompagnements: '',
equipmentsAndServices: ['ordinateurs', 'imprimantes'],
nbComputers: 10,
nbPrinters: 1,
hours: {
......@@ -289,7 +286,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young'],
......@@ -305,7 +301,7 @@ module.exports = {
address: {
numero: '7',
street: 'Rue Saint Polycarpe',
commune: 'Lyon 1er Arrondissement',
commune: 'Lyon 1er',
},
hours: {
monday: {
......@@ -362,7 +358,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young'],
......@@ -484,7 +479,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: [
'computer',
'internet',
......@@ -607,7 +601,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet', 'smartphone', 'mail'],
advancedSkills: ['cyberAndConf', 'photoVideo', 'devAndRobots', 'numericalCitizenship', 'responsibleDigital'],
age: ['young'],
......@@ -710,7 +703,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: ['computer', 'scanner'],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels', 'reconditionnementsDeMateriel', 'accesLivresInformatiques'],
baseSkills: ['computer', 'internet', 'smartphone', 'mail', 'work', 'officeAutomation', 'communication'],
advancedSkills: [
'cyberAndConf',
......@@ -821,7 +813,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: [],
solidarityMaterial: [],
equipmentsServices: ['donDeMateriels'],
baseSkills: ['computer', 'internet', 'officeAutomation', 'communication', 'data', 'scolarity'],
advancedSkills: [
'cyberAndConf',
......@@ -880,7 +871,7 @@ module.exports = {
address: {
numero: '172',
street: 'Avenue Général Frère',
commune: 'Lyon',
commune: 'Lyon 8e',
},
createdAt: '2020-11-13T14:13:00.000Z',
updatedAt: '2022-04-13T14:13:00.000Z',
......@@ -896,7 +887,6 @@ module.exports = {
onlineProcedures: [],
selfServiceMaterial: [],
solidarityMaterial: [],
equipmentsServices: [],
baseSkills: ['scolarity'],
advancedSkills: ['cyberAndConf'],
age: ['adults'],
......
import { Db, Cursor } from 'mongodb';
import { StructureDocument } from '../../structures/schemas/structure.schema';
import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({});
let document: StructureDocument;
while ((document = await cursor.next())) {
const newDoc = updateStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log("Updated : removed 'Arrondissement' from structure's commune ");
};
export const down = async () => {
const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({});
let document: StructureDocument;
while ((document = await cursor.next())) {
const newDoc = downgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
}
console.log("Downgraded : added 'Arrondissement' to structure's commune");
};
function updateStructure(doc: StructureDocument): StructureDocument {
if (doc?.address?.commune && doc.address.commune.startsWith('Lyon')) {
doc.address.commune = doc.address.commune.replace('er Arrondissement', 'er');
doc.address.commune = doc.address.commune.replace('ème Arrondissement', 'e');
}
return doc;
}
function downgradeStructure(doc: StructureDocument) {
if (doc?.address?.commune && doc.address.commune.startsWith('Lyon')) {
// First arrondissement
if (doc.address.commune.endsWith('er')) {
doc.address.commune = doc.address.commune + ' Arrondissement';
return doc;
}
// Other arrondissement
if (doc.address.commune.endsWith('e')) {
doc.address.commune = doc.address.commune.slice(0, -1) + 'ème Arrondissement';
return doc;
}
}
return doc;
}
......@@ -66,6 +66,7 @@ const upgradeStructure = (doc: any): StructureDocument => {
delete doc.parentingHelp;
delete doc.socialAndProfessional;
delete doc.digitalCultureSecurity;
delete doc.equipmentsServices;
return doc;
};
......
......@@ -19,4 +19,7 @@ export class OnlineMediationDto {
@IsNotEmpty()
readonly dateSlot: { day: string; hours: string };
@IsNotEmpty()
readonly preferredLanguage: string;
}
......@@ -19,6 +19,9 @@ export class OnlineMediation {
@Prop()
dateSlot: { day: string; hours: string };
@Prop()
preferredLanguage: string;
}
export const OnlineMediationSchema = SchemaFactory.createForClass(OnlineMediation);
......@@ -73,6 +73,7 @@ describe('userRegistryService', () => {
onlineDemarchType: ['Démarches Métropolitaines', 'CPAM'],
phone: '65 65',
surname: 'teztrfzegfv',
preferredLanguage: 'Français',
};
mockOnlineMediationModel.create.mockResolvedValueOnce(res);
expect(await service.create(res)).toStrictEqual(res);
......
......@@ -67,6 +67,17 @@ describe('PersonalOffersController', () => {
});
describe('create personal offer', () => {
it('should return 204 if personal offer is empty', async () => {
const req = { user: { _id: '6036721022462b001334c4bb' } };
try {
await controller.create(req, createPersonalOffersDtoDataMock[3]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Empty personal offer');
expect(e.status).toBe(204);
}
});
it('should create personal offer for existing user and structure', async () => {
const req = { user: { _id: '6036721022462b001334c4bb' } };
expect(await controller.create(req, createPersonalOffersDtoDataMock[0])).toEqual(personalOffersDataMock[0]);
......
import { Body, Controller, Delete, Get, Param, Post, Put, Request, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Delete,
Get,
HttpException,
HttpStatus,
Param,
Post,
Put,
Request,
UseGuards,
} from '@nestjs/common';
import { ApiBody, ApiParam, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { StructuresService } from '../structures/services/structures.service';
......@@ -43,6 +55,10 @@ export class PersonalOffersController {
@Body() createPersonalOfferDto: CreatePersonalOfferDto
): Promise<PersonalOfferDocument> {
const user: IUser = req.user;
const isEmpty = Object.values(createPersonalOfferDto.personalOffer.categories).every((value) => value.length === 0);
if (isEmpty) {
throw new HttpException('Empty personal offer', HttpStatus.NO_CONTENT);
}
const personalOfferDocument: PersonalOfferDocument = await this.personalOffersService.create(
createPersonalOfferDto
);
......
import { Module } from '@nestjs/common';
import { forwardRef, Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { StructuresModule } from '../structures/structures.module';
import { UsersModule } from '../users/users.module';
......@@ -9,10 +9,11 @@ import { PersonalOffer, PersonalOfferSchema } from './schemas/personal-offer.sch
@Module({
imports: [
MongooseModule.forFeature([{ name: PersonalOffer.name, schema: PersonalOfferSchema }]),
StructuresModule,
forwardRef(() => StructuresModule),
UsersModule,
],
controllers: [PersonalOffersController],
exports: [PersonalOffersService],
providers: [PersonalOffersService],
})
export class PersonalOffersModule {}
import { StructuresServiceMock } from './../../test/mock/services/structures.mock.service';
import { StructuresService } from './../structures/services/structures.service';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import {
......@@ -6,6 +8,8 @@ import {
personalOffersDataMock,
} from '../../test/mock/data/personalOffers.mock.data';
import { PersonalOffersService } from './personal-offers.service';
import { UsersService } from '../users/services/users.service';
import { UsersServiceMock } from '../../test/mock/services/user.mock.service';
describe('PersonalOffersService', () => {
let service: PersonalOffersService;
......@@ -26,6 +30,14 @@ describe('PersonalOffersService', () => {
provide: getModelToken('PersonalOffer'),
useValue: personalOfferModelMock,
},
{
provide: StructuresService,
useClass: StructuresServiceMock,
},
{
provide: UsersService,
useClass: UsersServiceMock,
},
],
}).compile();
......
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { UsersService } from './../users/services/users.service';
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { StructuresService } from '../structures/services/structures.service';
import { CreatePersonalOfferDto } from './dto/create-personal-offer.dto';
import { PersonalOfferDto } from './dto/personal-offer.dto';
import { PersonalOffer, PersonalOfferDocument } from './schemas/personal-offer.schema';
@Injectable()
export class PersonalOffersService {
constructor(@InjectModel(PersonalOffer.name) private personalOfferModel: Model<PersonalOfferDocument>) {}
private readonly logger = new Logger(PersonalOffersService.name);
constructor(
private structuresService: StructuresService,
private usersService: UsersService,
@InjectModel(PersonalOffer.name) private personalOfferModel: Model<PersonalOfferDocument>
) {}
public async findOne(id: string): Promise<PersonalOffer> {
this.logger.debug(`findOne`);
const result: PersonalOfferDocument = await this.personalOfferModel.findById(id).exec();
if (!result) {
throw new HttpException('Personal offer does not exist', HttpStatus.NOT_FOUND);
......@@ -18,10 +27,12 @@ export class PersonalOffersService {
}
public async create(createDto: CreatePersonalOfferDto): Promise<PersonalOfferDocument> {
this.logger.debug(`create`);
return this.personalOfferModel.create(createDto.personalOffer);
}
public async update(id: string, updatePersonalOfferDto: PersonalOfferDto): Promise<PersonalOfferDocument> {
this.logger.debug(`updating personal offer | ${id}`);
const result: PersonalOfferDocument = await this.personalOfferModel
.findByIdAndUpdate(id, updatePersonalOfferDto)
.exec();
......@@ -31,11 +42,20 @@ export class PersonalOffersService {
return result;
}
/**
* Delete a personal offer and remove it from both user and structure offers
*/
public async delete(id: string): Promise<PersonalOfferDocument> {
const result: PersonalOfferDocument = await this.personalOfferModel.findByIdAndDelete(id).exec();
if (!result) {
this.logger.debug(`delete`);
const structure = await this.structuresService.findByPersonalOfferId(id);
this.structuresService.removePersonalOffer(structure, id);
const user = await this.usersService.findByPersonalOfferId(id);
this.usersService.removePersonalOffer(user, id);
const deletedOffer: PersonalOfferDocument = await this.personalOfferModel.findByIdAndDelete(id).exec();
if (!deletedOffer) {
throw new HttpException('Invalid personal offer id for deletion', HttpStatus.BAD_REQUEST);
}
return result;
return deletedOffer;
}
}
......@@ -47,6 +47,8 @@ export class StructureDto {
pmrAccess: boolean;
remoteAccompaniment: boolean;
@IsNotEmpty()
categories: any;
@ApiProperty({ required: true })
......
export interface CNFSStructure {
id: string;
nom: string;
telephone?: string;
courriel?: string;
site_web?: string;
latitude: number;
longitude: number;
code_postal: string;
commune: string;
code_postal: string;
adresse: string;
[key: string]: string | number;
latitude: number;
longitude: number;
courriel?: string;
source: string;
date_maj: string;
services: string;
conditions_access: string;
labels_nationaux: string;
pivot?: string;
horaires?: string;
site_web?: string;
telephone?: string;
}
......@@ -15,6 +15,7 @@ import { ApticStructure } from '../schemas/aptic-structure.schema';
import { Structure, StructureDocument } from '../schemas/structure.schema';
import { StructureTypeService } from './../structure-type/structure-type.service';
import { StructuresSearchService } from './structures-search.service';
import { StructuresService } from './structures.service';
@Injectable()
export class ApticStructuresService {
......@@ -23,6 +24,7 @@ export class ApticStructuresService {
private readonly httpService: HttpService,
private readonly userService: UsersService,
private readonly categoriesService: CategoriesService,
private structureService: StructuresService,
private structuresSearchService: StructuresSearchService,
private structureTypeService: StructureTypeService,
@InjectModel(Structure.name) private structureModel: Model<StructureDocument>
......@@ -41,6 +43,7 @@ export class ApticStructuresService {
return this.getApticStructures(postalCode).subscribe(
(res) => {
res.data.presencePoints.forEach((structure) => {
this.logger.debug(`formatApticStructures | postal code: ${postalCode} | received : '${structure.name}'`);
// Call aptic api for offer
this.getApticStructureOffer(structure.catalogs[0]).subscribe(
(serviceData) => {
......@@ -72,6 +75,7 @@ export class ApticStructuresService {
if (!exist) {
this.logger.log(`createApticStructures | Create structure : ${structure.name}`);
const createdStructure = new this.structureModel();
createdStructure.categories = {};
// Known fields
createdStructure.structureName = structure.name;
createdStructure.contactPhone = structure.phone;
......@@ -91,7 +95,6 @@ export class ApticStructuresService {
createdStructure.coord = [structure.address.gpsLng, structure.address.gpsLat];
createdStructure.address = this.formatAddress(structure);
// Set structure offer
createdStructure.categories = {};
createdStructure.categories.selfServiceMaterial = await this.setModules(structure, 'selfServiceMaterial');
createdStructure.categories.solidarityMaterial = await this.setModules(structure, 'solidarityMaterial');
createdStructure.categories.onlineProcedures = await this.setModules(structure, 'onlineProcedures');
......@@ -224,10 +227,10 @@ export class ApticStructuresService {
* Get Metropole new aptic structure evey week. For testing, please change the expression
*/
@Cron(CronExpression.EVERY_WEEK)
public getMetopoleMunicipality(): void {
public getMetropoleMunicipality(): void {
const req =
'https://download.data.grandlyon.com/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json?maxfeatures=-1&start=1';
this.logger.log(`getMetopoleMunicipality | Request : ${req}`, '');
this.logger.log(`getMetropoleMunicipality | Request : ${req}`, '');
this.httpService.get(encodeURI(req)).subscribe(
(data) => {
const inseeArray = data.data.values.map((municipality) => {
......@@ -246,7 +249,7 @@ export class ApticStructuresService {
public getPostalCodeWithINSEE(inseeCode: string): Observable<AxiosResponse<any>> {
const req = `https://geo.api.gouv.fr/communes/${inseeCode}?fields=codesPostaux&format=json`;
this.logger.debug(`getMetopoleMunicipality | Request : ${req}`);
this.logger.debug(`getMetropoleMunicipality | Request : ${req}`);
return this.httpService.get(encodeURI(req));
}
......@@ -299,7 +302,8 @@ export class ApticStructuresService {
} else {
address.street = structure.address.main;
}
address.commune = structure.address.city;
address.commune = this.structureService.getFormattedCity(structure.address.city, structure.address.zip);
return address;
}
}
import { Injectable, Logger } from '@nestjs/common';
import { ElasticsearchService } from '@nestjs/elasticsearch';
import { Structure, StructureDocument } from '../schemas/structure.schema';
import { es_settings_homemade_french } from '../../shared/utils';
import { StructureSearchBody } from '../interfaces/structure-search-body.interface';
import { StructureSearchResult } from '../interfaces/structure-search-response.interface';
import { es_settings_homemade_french } from '../../shared/utils';
import { StructureDocument } from '../schemas/structure.schema';
@Injectable()
export class StructuresSearchService {
......@@ -17,17 +17,21 @@ export class StructuresSearchService {
this.elasticsearchService.index<StructureSearchResult, StructureSearchBody>({
index: this.index,
id: structure._id,
body: {
structureName: structure.structureName,
structureType: structure.structureType.value,
structureId: structure._id,
address: structure.address,
description: structure.description,
},
body: this.formatIndexBody(structure),
});
return structure;
}
private formatIndexBody(structure: StructureDocument): StructureSearchBody {
return {
structureName: structure.structureName,
structureType: structure.structureType.value,
structureId: structure._id,
address: structure.address,
description: structure.description,
};
}
public async createStructureIndex(): Promise<any> {
this.logger.debug(`createStructureIndex`);
// use custom analyzer with minimal_french stemmer to avoid default light_french stemmer problems (oullins -> oulin, "oull" not found)
......@@ -116,19 +120,13 @@ export class StructuresSearchService {
return sortedHits.map((item) => item._source);
}
public async update(structure: Structure, id: string): Promise<any> {
public async update(structure: StructureDocument, id: string): Promise<any> {
this.logger.debug('update');
return this.elasticsearchService.update({
index: this.index,
id: id,
body: {
doc: {
structureName: structure.structureName,
structureType: structure.structureType,
structureId: id,
address: structure.address,
description: structure.description,
},
doc: this.formatIndexBody(structure),
},
});
}
......