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

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Commits on Source (8)
Showing
with 6230 additions and 5387 deletions
...@@ -2,6 +2,20 @@ ...@@ -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. 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](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta5...v2.0.0) (2022-12-02)
### ⚠ BREAKING CHANGES
* **deps:** mongoose and axios updates.
### Bug Fixes
* **structure:** issues ([8587561](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/858756190cd2c0e805726e9b09c65c3193ba00e6))
* **deps:** major updates of libs ([6b411a7](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/6b411a74b364af6efec1b082a0f7981f4a1e14b5))
## [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) ## [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)
......
{
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/src/.*\\.(test|spec).(ts|tsx|js)$",
"collectCoverageFrom": ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],
"coverageReporters": ["json", "lcov"],
"reporters": ["default", "jest-junit"]
}
This diff is collapsed.
{ {
"name": "ram_server", "name": "ram_server",
"private": true, "private": true,
"version": "2.0.0-beta5", "version": "2.0.0",
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"release": "standard-version", "release": "standard-version",
"init-db": "node ./scripts/init-db.js", "init-db": "node ./scripts/init-db.js",
"test": "jest --config ./test/jest.json --coverage", "test": "jest --config ./jest.json --coverage",
"test:watch": "jest --config ./test/jest.json --watch --coverage", "test:watch": "jest --config ./jest.json --watch --coverage",
"test:cov": "jest --config ./test/jest.json --coverage --ci --reporters=default --reporters=jest-junit", "test:cov": "jest --config ./jest.json --coverage --ci --reporters=default --reporters=jest-junit",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json", "test:e2e": "jest --config ./test/jest-e2e.json",
"migrate:create": "migrate create --template-file ./src/migrations/migrations-utils/template.ts --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\"", "migrate:create": "migrate create --template-file ./src/migrations/migrations-utils/template.ts --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\"",
...@@ -27,40 +27,39 @@ ...@@ -27,40 +27,39 @@
"migrate:down": "migrate --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\" down" "migrate:down": "migrate --migrations-dir=\"./src/migrations/scripts\" --compiler=\"ts:./src/migrations/migrations-utils/ts-compiler.js\" down"
}, },
"dependencies": { "dependencies": {
"@elastic/elasticsearch": "^7.12.0", "@elastic/elasticsearch": "~8.5.0",
"@mailchimp/mailchimp_marketing": "^3.0.78", "@mailchimp/mailchimp_marketing": "^3.0.80",
"@nestjs/axios": "^0.1.0", "@nestjs/axios": "^1.0.0",
"@nestjs/common": "^9.0.11", "@nestjs/common": "^9.0.11",
"@nestjs/config": "^0.6.3", "@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.11", "@nestjs/core": "^9.0.11",
"@nestjs/elasticsearch": "^7.1.0", "@nestjs/elasticsearch": "^9.0.0",
"@nestjs/jwt": "^7.2.0", "@nestjs/jwt": "^9.0.0",
"@nestjs/mongoose": "^7.1.0", "@nestjs/mongoose": "^9.2.1",
"@nestjs/passport": "^7.1.5", "@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.11", "@nestjs/platform-express": "^9.2.0",
"@nestjs/schedule": "^0.4.1", "@nestjs/schedule": "^0.4.1",
"@nestjs/swagger": "^6.1.2", "@nestjs/swagger": "^6.1.3",
"@tryghost/admin-api": "^1.4.4", "@tryghost/admin-api": "^1.13.1",
"@types/bcrypt": "^3.0.0", "@types/bcrypt": "^5.0.0",
"axios": "^0.27.2", "axios": "1.1.3",
"bcrypt": "^5.0.1", "bcrypt": "^5.1.0",
"class-transformer": "^0.3.1", "class-transformer": "^0.5.1",
"class-validator": "^0.13.0", "class-validator": "^0.13.2",
"dotenv": "^8.2.0", "dotenv": "^16.0.3",
"ejs": "^3.1.7", "ejs": "^3.1.8",
"form-data": "^3.0.0", "form-data": "^4.0.0",
"luxon": "^1.25.0", "luxon": "^1.25.0",
"migrate": "^1.7.0", "migrate": "^1.8.0",
"mongoose": "^5.10.15", "mongoose": "^6.7.3",
"passport": "^0.6.0", "passport": "^0.6.0",
"passport-jwt": "^4.0.0", "passport-jwt": "^4.0.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.5.7", "rxjs": "^7.5.5",
"sanitize-html": "^2.6.1", "sanitize-html": "^2.7.3",
"standard-version": "^9.3.2", "swagger-ui-express": "^4.6.0"
"swagger-ui-express": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@compodoc/compodoc": "^1.1.16", "@compodoc/compodoc": "^1.1.16",
...@@ -70,7 +69,6 @@ ...@@ -70,7 +69,6 @@
"@nestjs/testing": "^9.0.11", "@nestjs/testing": "^9.0.11",
"@types/express": "^4.17.8", "@types/express": "^4.17.8",
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/mongoose": "^5.10.1",
"@types/node": "^14.14.6", "@types/node": "^14.14.6",
"@types/passport-local": "^1.0.33", "@types/passport-local": "^1.0.33",
"@types/supertest": "^2.0.10", "@types/supertest": "^2.0.10",
...@@ -79,13 +77,14 @@ ...@@ -79,13 +77,14 @@
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-config-prettier": "^6.15.0", "eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^26.6.3", "jest": "28.1.2",
"jest-junit": "^14.0.0", "jest-junit": "^14.0.0",
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"standard-version": "^9.5.0",
"supertest": "^6.0.0", "supertest": "^6.0.0",
"ts-jest": "^26.4.3", "ts-jest": "^28.0.5",
"ts-loader": "^8.0.8", "ts-loader": "^9.4.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"typescript": "^4.2.4" "typescript": "^4.2.4"
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "extends": [
"local>systemes-dinformation/renovate/renovate-config" "local>systemes-dinformation/renovate/renovate-config"
] ],
"labels": ["dependencies"]
} }
...@@ -365,5 +365,24 @@ module.exports = { ...@@ -365,5 +365,24 @@ module.exports = {
theme: 'Public', theme: 'Public',
id: 'publicOthers', 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',
},
], ],
}; };
...@@ -28,7 +28,6 @@ const param = ...@@ -28,7 +28,6 @@ const param =
mongoose.connect(param, { useNewUrlParser: true, useUnifiedTopology: true }).catch((error) => console.log(error)); mongoose.connect(param, { useNewUrlParser: true, useUnifiedTopology: true }).catch((error) => console.log(error));
// Make Mongoose use `findOneAndUpdate()`. Note that this option is `true` // Make Mongoose use `findOneAndUpdate()`. Note that this option is `true`
// by default, you need to set it to false. // by default, you need to set it to false.
mongoose.set('useFindAndModify', false);
function hashPassword() { function hashPassword() {
return bcrypt.hashSync(process.env.USER_PWD, process.env.SALT); return bcrypt.hashSync(process.env.USER_PWD, process.env.SALT);
......
...@@ -210,7 +210,7 @@ describe('AdminController', () => { ...@@ -210,7 +210,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer'); const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = '6231aefe76598527c8d0b5bc'; const mockUserId = '6231aefe76598527c8d0b5bc';
const mockEmployer = { const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra', name: 'Sopra',
validated: true, validated: true,
}; };
...@@ -228,7 +228,7 @@ describe('AdminController', () => { ...@@ -228,7 +228,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer'); const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = '6231aefe76598527c8d0b5bc'; const mockUserId = '6231aefe76598527c8d0b5bc';
const mockEmployer = { const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra', name: 'Sopra',
validated: true, validated: true,
}; };
...@@ -250,7 +250,7 @@ describe('AdminController', () => { ...@@ -250,7 +250,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer'); const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = 'thisuserdoesnotexist'; const mockUserId = 'thisuserdoesnotexist';
const mockEmployer = { const mockEmployer = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra', name: 'Sopra',
validated: true, validated: true,
}; };
...@@ -274,7 +274,7 @@ describe('AdminController', () => { ...@@ -274,7 +274,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob'); const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = '6231aefe76598527c8d0b5bc'; const mockUserId = '6231aefe76598527c8d0b5bc';
const mockJob = { const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Toto', name: 'Toto',
validated: true, validated: true,
}; };
...@@ -292,7 +292,7 @@ describe('AdminController', () => { ...@@ -292,7 +292,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob'); const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = '6231aefe76598527c8d0b5bc'; const mockUserId = '6231aefe76598527c8d0b5bc';
const mockJob = { const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Dev', name: 'Dev',
validated: true, validated: true,
}; };
...@@ -314,7 +314,7 @@ describe('AdminController', () => { ...@@ -314,7 +314,7 @@ describe('AdminController', () => {
const spyer = jest.spyOn(userService, 'updateUserJob'); const spyer = jest.spyOn(userService, 'updateUserJob');
const mockUserId = 'thisuserdoesntexist'; const mockUserId = 'thisuserdoesntexist';
const mockJob = { const mockJob = {
_id: Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Dev', name: 'Dev',
validated: true, validated: true,
}; };
......
...@@ -219,8 +219,8 @@ export class AdminController { ...@@ -219,8 +219,8 @@ export class AdminController {
return formatUsers.map((user) => { return formatUsers.map((user) => {
return { return {
id: user._id, id: user._id,
createdAt: user.createdAt ? user.createdAt.toLocaleDateString() : '', createdAt: user.createdAt ? user.createdAt.toLocaleDateString('fr-FR') : '',
unattachedSince: user.unattachedSince ? user.unattachedSince.toLocaleDateString() : '', unattachedSince: user.unattachedSince ? user.unattachedSince.toLocaleDateString('fr-FR') : '',
surname: user.surname, surname: user.surname,
name: user.name, name: user.name,
email: user.email, email: user.email,
......
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt'; import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import * as dotenv from 'dotenv'; import { config } from 'dotenv';
import { UsersModule } from '../users/users.module'; import { UsersModule } from '../users/users.module';
import { AuthController } from './auth.controller'; import { AuthController } from './auth.controller';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { JwtStrategy } from './strategy/jwt.strategy'; import { JwtStrategy } from './strategy/jwt.strategy';
dotenv.config(); config();
@Module({ @Module({
imports: [ imports: [
......
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import { config } from './config'; import { config } from './config';
import { configProd } from './config.prod';
import { configDev } from './config.dev'; import { configDev } from './config.dev';
import { configProd } from './config.prod';
import { configRec } from './config.rec'; import { configRec } from './config.rec';
export class ConfigurationService { export class ConfigurationService {
private readonly _config; private readonly _config;
......
import { MongoClient } from 'mongodb';
import { config } from 'dotenv'; import { config } from 'dotenv';
import { MongoClient } from 'mongodb';
export const getDb = async () => { export const getDb = async () => {
config(); // Required for reading .env config(); // Required for reading .env
const client: MongoClient = await MongoClient.connect( const client: MongoClient = await MongoClient.connect(
`mongodb://${process.env.MONGO_NON_ROOT_USERNAME}:${process.env.MONGO_NON_ROOT_PASSWORD}@${process.env.MONGO_DB_HOST_AND_PORT}/ram`, `mongodb://${process.env.MONGO_NON_ROOT_USERNAME}:${process.env.MONGO_NON_ROOT_PASSWORD}@${process.env.MONGO_DB_HOST_AND_PORT}/ram`
{ useUnifiedTopology: true }
); );
return client.db(); return client.db();
}; };
import { Db, Cursor } from 'mongodb'; import { Db } from 'mongodb';
import { StructureDocument } from '../../structures/schemas/structure.schema'; import { StructureDocument } from '../../structures/schemas/structure.schema';
import { getDb } from '../migrations-utils/db'; import { getDb } from '../migrations-utils/db';
export const up = async () => { export const up = async () => {
const db: Db = await getDb(); const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({}); const cursor = db.collection('structures').find({});
let document: StructureDocument; let document;
while ((document = await cursor.next())) { while ((document = await cursor.next())) {
const newDoc = updateStructure(document); const newDoc: StructureDocument = updateStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]); await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
} }
console.log("Updated : removed 'Arrondissement' from structure's commune "); console.log("Updated : removed 'Arrondissement' from structure's commune ");
...@@ -15,10 +15,10 @@ export const up = async () => { ...@@ -15,10 +15,10 @@ export const up = async () => {
export const down = async () => { export const down = async () => {
const db: Db = await getDb(); const db: Db = await getDb();
const cursor: Cursor<StructureDocument> = db.collection('structures').find({}); const cursor = db.collection('structures').find({});
let document: StructureDocument; let document;
while ((document = await cursor.next())) { while ((document = await cursor.next())) {
const newDoc = downgradeStructure(document); const newDoc: StructureDocument = downgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]); await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
} }
console.log("Downgraded : added 'Arrondissement' to structure's commune"); console.log("Downgraded : added 'Arrondissement' to structure's commune");
......
...@@ -3,7 +3,8 @@ import { getDb } from '../migrations-utils/db'; ...@@ -3,7 +3,8 @@ import { getDb } from '../migrations-utils/db';
export const up = async () => { export const up = async () => {
const db: Db = await getDb(); const db: Db = await getDb();
await db.collection('tclstoppoints').updateMany({}, { $pull: { busLines: { $in: ['PL1', 'PL2', 'PL3'] } } }); //Removed after mongosse migration. It's now useless, it's handled by tcl service directly
// await db.collection('tclstoppoints').updateMany({}, { $pull: { busLines: { $in: ['PL1', 'PL2', 'PL3'] } } });
await db.collection('tclstoppoints').deleteMany({ await db.collection('tclstoppoints').deleteMany({
$and: [{ tramLines: { $size: 0 } }, { subLines: { $size: 0 } }, { busLines: { $size: 0 } }], $and: [{ tramLines: { $size: 0 } }, { subLines: { $size: 0 } }, { busLines: { $size: 0 } }],
}); });
......
...@@ -10,7 +10,7 @@ export const up = async () => { ...@@ -10,7 +10,7 @@ export const up = async () => {
// Create categories fields // Create categories fields
let document; let document;
while ((document = await cursor.next())) { while ((document = await cursor.next())) {
const newDoc = upgradeStructure(document); const newDoc: StructureDocument = upgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]); await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
} }
console.log(`Update done : new structrure repository ref`); console.log(`Update done : new structrure repository ref`);
...@@ -29,9 +29,9 @@ export const up = async () => { ...@@ -29,9 +29,9 @@ export const up = async () => {
export const down = async () => { export const down = async () => {
const db: Db = await getDb(); const db: Db = await getDb();
const cursor = db.collection('structures').find({}); const cursor = db.collection('structures').find({});
let document: StructureDocument; let document;
while ((document = await cursor.next())) { while ((document = await cursor.next())) {
const newDoc = downgradeStructure(document); const newDoc: StructureDocument = downgradeStructure(document);
await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]); await db.collection('structures').updateOne({ _id: document._id }, [{ $set: newDoc }]);
} }
console.log(`Downgrade done : new structrure repository removed`); console.log(`Downgrade done : new structrure repository removed`);
...@@ -310,6 +310,7 @@ const mapPublics = (doc: any): StructureDocument => { ...@@ -310,6 +310,7 @@ const mapPublics = (doc: any): StructureDocument => {
const languageAndIlliteracy = []; const languageAndIlliteracy = [];
const handicaps = []; const handicaps = [];
const publicOthers = []; const publicOthers = [];
const solidarityMaterial = [];
doc.publics?.forEach((el) => { doc.publics?.forEach((el) => {
switch (el) { switch (el) {
case 'toutPublic': case 'toutPublic':
...@@ -368,5 +369,6 @@ const mapPublics = (doc: any): StructureDocument => { ...@@ -368,5 +369,6 @@ const mapPublics = (doc: any): StructureDocument => {
doc.categories.languageAndIlliteracy = languageAndIlliteracy; doc.categories.languageAndIlliteracy = languageAndIlliteracy;
doc.categories.handicaps = handicaps; doc.categories.handicaps = handicaps;
doc.categories.publicOthers = publicOthers; doc.categories.publicOthers = publicOthers;
doc.categories.solidarityMaterial = solidarityMaterial;
return doc; return doc;
}; };
import { Db } from 'mongodb'; import { Db } from 'mongodb';
import { StructureType } from '../../structures/structure-type/structure-type.schema'; import { StructureTypeDocument } from '../../structures/structure-type/structure-type.schema';
import { getDb } from '../migrations-utils/db'; import { getDb } from '../migrations-utils/db';
export const up = async () => { export const up = async () => {
const db: Db = await getDb(); const db: Db = await getDb();
const cursor = db.collection('structuretype').find({}); const cursor = db.collection('structuretype').find({});
let document: StructureType; let document;
const documents = []; const documents = [];
// List documents to process // List documents to process
while ((document = await cursor.next())) { while ((document = await cursor.next())) {
...@@ -24,7 +24,9 @@ export const up = async () => { ...@@ -24,7 +24,9 @@ export const up = async () => {
let structure; let structure;
while ((structure = await cursorStructure.next())) { while ((structure = await cursorStructure.next())) {
if (structure.structureType) { if (structure.structureType) {
const structureType = await db.collection('structuretype').findOne({ value: structure.structureType }); const structureType = await db
.collection('structuretype')
.findOne<StructureTypeDocument>({ value: structure.structureType });
await db await db
.collection('structures') .collection('structures')
.updateOne({ _id: structure._id }, { $set: { structureType: structureType ? structureType._id : null } }); .updateOne({ _id: structure._id }, { $set: { structureType: structureType ? structureType._id : null } });
...@@ -41,7 +43,9 @@ export const down = async () => { ...@@ -41,7 +43,9 @@ export const down = async () => {
let structure; let structure;
while ((structure = await cursorStructure.next())) { while ((structure = await cursorStructure.next())) {
if (structure.structureType) { if (structure.structureType) {
const structureType = await db.collection('structuretype').findOne({ _id: structure.structureType }); const structureType = await db
.collection('structuretype')
.findOne<StructureTypeDocument>({ _id: structure.structureType });
await db await db
.collection('structures') .collection('structures')
.updateOne({ _id: structure._id }, { $set: { structureType: structureType.value } }); .updateOne({ _id: structure._id }, { $set: { structureType: structureType.value } });
...@@ -49,7 +53,7 @@ export const down = async () => { ...@@ -49,7 +53,7 @@ export const down = async () => {
} }
const cursor = db.collection('structuretype').find({}); const cursor = db.collection('structuretype').find({});
let document: StructureType; let document;
const documents = []; const documents = [];
// List documents to process // List documents to process
......
...@@ -3,6 +3,10 @@ import { Document } from 'mongoose'; ...@@ -3,6 +3,10 @@ import { Document } from 'mongoose';
export type OnlineMediationDocument = OnlineMediation & Document; export type OnlineMediationDocument = OnlineMediation & Document;
class DateSlot {
day: string;
hours: string;
}
@Schema() @Schema()
export class OnlineMediation { export class OnlineMediation {
@Prop() @Prop()
...@@ -17,8 +21,8 @@ export class OnlineMediation { ...@@ -17,8 +21,8 @@ export class OnlineMediation {
@Prop() @Prop()
onlineDemarchType: string[]; onlineDemarchType: string[];
@Prop() @Prop({ type: DateSlot })
dateSlot: { day: string; hours: string }; dateSlot: DateSlot;
@Prop() @Prop()
preferredLanguage: string; preferredLanguage: string;
......
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose'; import { Document } from 'mongoose';
import { StructureCategories } from '../../structures/schemas/structureCategories.schema';
export type PersonalOfferDocument = PersonalOffer & Document; export type PersonalOfferDocument = PersonalOffer & Document;
@Schema({ timestamps: true }) @Schema({ timestamps: true })
export class PersonalOffer { export class PersonalOffer {
@Prop() @Prop({ type: StructureCategories })
categories: any; categories: StructureCategories;
} }
export const PersonalOfferSchema = SchemaFactory.createForClass(PersonalOffer); export const PersonalOfferSchema = SchemaFactory.createForClass(PersonalOffer);
import { AnalysisAnalyzer, IndicesIndexSettings } from '@elastic/elasticsearch/lib/api/types';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { Page } from '../pages/schemas/page.schema'; import { Page } from '../pages/schemas/page.schema';
import { Post } from '../posts/schemas/post.schema'; import { Post } from '../posts/schemas/post.schema';
...@@ -22,7 +23,20 @@ export function hasAdminRole(user: User): boolean { ...@@ -22,7 +23,20 @@ export function hasAdminRole(user: User): boolean {
return user.role === UserRole.admin; return user.role === UserRole.admin;
} }
export const es_settings_homemade_french = { const analyzer: Record<string, AnalysisAnalyzer> = {
homemade_french: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stop', 'french_stemmer'],
},
homemade_french_stopless: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stemmer'],
},
};
export const es_settings_homemade_french: IndicesIndexSettings = {
analysis: { analysis: {
filter: { filter: {
french_elision: { french_elision: {
...@@ -39,15 +53,6 @@ export const es_settings_homemade_french = { ...@@ -39,15 +53,6 @@ export const es_settings_homemade_french = {
language: 'minimal_french', language: 'minimal_french',
}, },
}, },
analyzer: { analyzer: analyzer,
homemade_french: {
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stop', 'french_stemmer'],
},
homemade_french_stopless: {
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stemmer'],
},
},
}, },
}; };
import { StructureSearchBody } from './structure-search-body.interface';
export interface StructureSearchResult {
hits: {
total: number;
max_score: number;
hits: Array<{
_score: number;
_source: StructureSearchBody;
}>;
};
}