diff --git a/package-lock.json b/package-lock.json index 44e0b18..deebd04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "2.2.1", "license": "AGPL", "dependencies": { - "@grpc/grpc-js": "^1.9.7", + "@grpc/grpc-js": "^1.9.8", "@grpc/proto-loader": "^0.7.10", - "@mobicoop/configuration-module": "^4.1.0", + "@mobicoop/configuration-module": "^6.1.0", "@mobicoop/ddd-library": "^2.1.1", "@mobicoop/health-module": "^2.3.1", "@mobicoop/message-broker-module": "^2.1.1", @@ -29,8 +29,8 @@ "rimraf": "^5.0.5" }, "devDependencies": { - "@nestjs/cli": "^10.2.0", - "@nestjs/schematics": "^10.0.2", + "@nestjs/cli": "^10.2.1", + "@nestjs/schematics": "^10.0.3", "@nestjs/testing": "^10.2.7", "@types/express": "^4.17.20", "@types/jest": "29.5.6", @@ -89,9 +89,9 @@ } }, "node_modules/@angular-devkit/core": { - "version": "16.2.7", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-16.2.7.tgz", - "integrity": "sha512-XskObYrg7NRdEuHnSVZOM7OeinEL8HzugjmKnawAa+dAbFCCoGsVWjMliA/Q8sb1yfGkyL0WW7DZABZj7EGwWA==", + "version": "16.2.8", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-16.2.8.tgz", + "integrity": "sha512-PTGozYvh1Bin5lB15PwcXa26Ayd17bWGLS3H8Rs0s+04mUDvfNofmweaX1LgumWWy3nCUTDuwHxX10M3G0wE2g==", "dev": true, "dependencies": { "ajv": "8.12.0", @@ -116,12 +116,12 @@ } }, "node_modules/@angular-devkit/schematics": { - "version": "16.2.7", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-16.2.7.tgz", - "integrity": "sha512-zu3xHwA4w+kXHkyyjGl3i7uSU2/kKLPKuyyixw0WLcKUQCYd7TWmu8OC0qCDa42XkxP9gGL091dJFu56exgneA==", + "version": "16.2.8", + "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-16.2.8.tgz", + "integrity": "sha512-MBiKZOlR9/YMdflALr7/7w/BGAfo/BGTrlkqsIB6rDWV1dYiCgxI+033HsiNssLS6RQyCFx/e7JA2aBBzu9zEg==", "dev": true, "dependencies": { - "@angular-devkit/core": "16.2.7", + "@angular-devkit/core": "16.2.8", "jsonc-parser": "3.2.0", "magic-string": "0.30.1", "ora": "5.4.1", @@ -134,13 +134,13 @@ } }, "node_modules/@angular-devkit/schematics-cli": { - "version": "16.2.7", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics-cli/-/schematics-cli-16.2.7.tgz", - "integrity": "sha512-K10EE3qtSv4AoI3gnCNT80BbDNMK6UmpM8w0sd08hlNC4SCfzp+OFszV0AW29A5VK3zkbDQLJ6PL4wnNN4iuDQ==", + "version": "16.2.8", + "resolved": "https://registry.npmjs.org/@angular-devkit/schematics-cli/-/schematics-cli-16.2.8.tgz", + "integrity": "sha512-EXURJCzWTVYCipiTT4vxQQOrF63asOUDbeOy3OtiSh7EwIUvxm3BPG6hquJqngEnI/N6bA75NJ1fBhU6Hrh7eA==", "dev": true, "dependencies": { - "@angular-devkit/core": "16.2.7", - "@angular-devkit/schematics": "16.2.7", + "@angular-devkit/core": "16.2.8", + "@angular-devkit/schematics": "16.2.8", "ansi-colors": "4.1.3", "inquirer": "8.2.4", "symbol-observable": "4.0.0", @@ -1031,9 +1031,9 @@ ] }, "node_modules/@grpc/grpc-js": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.7.tgz", - "integrity": "sha512-yMaA/cIsRhGzW3ymCNpdlPcInXcovztlgu/rirThj2b87u3RzWUszliOqZ/pldy7yhmJPS8uwog+kZSTa4A0PQ==", + "version": "1.9.8", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.8.tgz", + "integrity": "sha512-FFPzDS333Vw8hvf+1FaEsaCYVPBdNdUCw7zArTiF7+6gOzln967b4GBCBekKGqoKEgna8d3Ayxv8t+IvazXG3g==", "dependencies": { "@grpc/proto-loader": "^0.7.8", "@types/node": ">=12.12.47" @@ -1668,9 +1668,9 @@ } }, "node_modules/@mobicoop/configuration-module": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@mobicoop/configuration-module/-/configuration-module-4.1.0.tgz", - "integrity": "sha512-j1C6S1S/v5nid9KeWVa97ZCVxwEbSWBP2oHzzRHazmgtO6lbybugnjQKtRHHKlnTMc1zGdD/4Xii/7JlGckflQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@mobicoop/configuration-module/-/configuration-module-6.1.0.tgz", + "integrity": "sha512-ar4hx+oB+RtgAj0SLg0/xgxHA7r/LnUz9BzXUlEX4va0AQwSPdFgTJhku6flMW4U0sJdtGEay3740BnqGfMtCw==", "dependencies": { "@songkeys/nestjs-redis": "^10.0.0", "ioredis": "^5.3.2" @@ -1738,21 +1738,21 @@ } }, "node_modules/@nestjs/cli": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@nestjs/cli/-/cli-10.2.0.tgz", - "integrity": "sha512-OMbn6A/YNu7QSk1nM8VucrtUwocaa0XEa9uoqRpw5Acvh/KIetvMHCn8L6yIBxiK7yvYiKa8q9U+RpLsKpKfgw==", + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/@nestjs/cli/-/cli-10.2.1.tgz", + "integrity": "sha512-CAJAQwmxFZfB3RTvqz/eaXXWpyU+mZ4QSqfBYzjneTsPgF+uyOAW3yQpaLNn9Dfcv39R9UxSuAhayv6yuFd+Jg==", "dev": true, "dependencies": { - "@angular-devkit/core": "16.2.7", - "@angular-devkit/schematics": "16.2.7", - "@angular-devkit/schematics-cli": "16.2.7", + "@angular-devkit/core": "16.2.8", + "@angular-devkit/schematics": "16.2.8", + "@angular-devkit/schematics-cli": "16.2.8", "@nestjs/schematics": "^10.0.1", "chalk": "4.1.2", "chokidar": "3.5.3", "cli-table3": "0.6.3", "commander": "4.1.1", - "fork-ts-checker-webpack-plugin": "9.0.0", - "glob": "10.3.4", + "fork-ts-checker-webpack-plugin": "9.0.2", + "glob": "10.3.10", "inquirer": "8.2.6", "node-emoji": "1.11.0", "ora": "5.4.1", @@ -2075,13 +2075,13 @@ } }, "node_modules/@nestjs/schematics": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-10.0.2.tgz", - "integrity": "sha512-DaZZjymYoIfRqC5W62lnYXIIods1PDY6CGc8+IpRwyinzffjKxZ3DF3exu+mdyvllzkXo9DTXkoX4zOPSJHCkw==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-10.0.3.tgz", + "integrity": "sha512-2BRujK0GqGQ7j1Zpz+obVfskDnnOeVKt5aXoSaVngKo8Oczy8uYCY+R547TQB+Kf35epdfFER2pVnQrX3/It5A==", "dev": true, "dependencies": { - "@angular-devkit/core": "16.1.8", - "@angular-devkit/schematics": "16.1.8", + "@angular-devkit/core": "16.2.8", + "@angular-devkit/schematics": "16.2.8", "comment-json": "4.2.3", "jsonc-parser": "3.2.0", "pluralize": "8.0.0" @@ -2090,62 +2090,6 @@ "typescript": ">=4.8.2" } }, - "node_modules/@nestjs/schematics/node_modules/@angular-devkit/core": { - "version": "16.1.8", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-16.1.8.tgz", - "integrity": "sha512-dSRD/+bGanArIXkj+kaU1kDFleZeQMzmBiOXX+pK0Ah9/0Yn1VmY3RZh1zcX9vgIQXV+t7UPrTpOjaERMUtVGw==", - "dev": true, - "dependencies": { - "ajv": "8.12.0", - "ajv-formats": "2.1.1", - "jsonc-parser": "3.2.0", - "rxjs": "7.8.1", - "source-map": "0.7.4" - }, - "engines": { - "node": "^16.14.0 || >=18.10.0", - "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", - "yarn": ">= 1.13.0" - }, - "peerDependencies": { - "chokidar": "^3.5.2" - }, - "peerDependenciesMeta": { - "chokidar": { - "optional": true - } - } - }, - "node_modules/@nestjs/schematics/node_modules/@angular-devkit/schematics": { - "version": "16.1.8", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-16.1.8.tgz", - "integrity": "sha512-6LyzMdFJs337RTxxkI2U1Ndw0CW5mMX/aXWl8d7cW2odiSrAg8IdlMqpc+AM8+CPfsB0FtS1aWkEZqJLT0jHOg==", - "dev": true, - "dependencies": { - "@angular-devkit/core": "16.1.8", - "jsonc-parser": "3.2.0", - "magic-string": "0.30.0", - "ora": "5.4.1", - "rxjs": "7.8.1" - }, - "engines": { - "node": "^16.14.0 || >=18.10.0", - "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", - "yarn": ">= 1.13.0" - } - }, - "node_modules/@nestjs/schematics/node_modules/magic-string": { - "version": "0.30.0", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", - "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", - "dev": true, - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.13" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@nestjs/swagger": { "version": "7.1.14", "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-7.1.14.tgz", @@ -2670,12 +2614,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/@types/parse-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.1.tgz", - "integrity": "sha512-3YmXzzPAdOTVljVMkTMBdBEvlOLg2cDQaDhnnhT3nT9uDbnJzjWhKlzb+desT12Y7tGqaN6d+AbozcKzyL36Ng==", - "dev": true - }, "node_modules/@types/qs": { "version": "6.9.9", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.9.tgz", @@ -4277,19 +4215,29 @@ } }, "node_modules/cosmiconfig": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", - "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", + "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", "dev": true, "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" + "import-fresh": "^3.3.0", + "js-yaml": "^4.1.0", + "parse-json": "^5.2.0", + "path-type": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/create-jest": { @@ -5477,15 +5425,15 @@ } }, "node_modules/fork-ts-checker-webpack-plugin": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.0.0.tgz", - "integrity": "sha512-Kw3JjsfGs0piB0V2Em8gCuo51O3p4KyCOK0Tn8X57oq2mSNBrMmONALRBw5frcmWsOVU7iELXXsJ+FVxJeQuhA==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.0.2.tgz", + "integrity": "sha512-Uochze2R8peoN1XqlSi/rGUkDQpRogtLFocP9+PGu68zk1BDAKXfdeCdyVZpgTk8V8WFVQXdEz426VKjXLO1Gg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.16.7", "chalk": "^4.1.2", "chokidar": "^3.5.3", - "cosmiconfig": "^7.0.1", + "cosmiconfig": "^8.2.0", "deepmerge": "^4.2.2", "fs-extra": "^10.0.0", "memfs": "^3.4.1", @@ -5649,19 +5597,18 @@ } }, "node_modules/glob": { - "version": "10.3.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.4.tgz", - "integrity": "sha512-6LFElP3A+i/Q8XQKEvZjkEWEOTgAIALR9AO2rwT8bgPhDd1anmqDJDZ6lLddI4ehxxxR1S5RIqKe1uapMQfYaQ==", - "dev": true, + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.0.3", + "jackspeak": "^2.3.5", "minimatch": "^9.0.1", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", "path-scurry": "^1.10.1" }, "bin": { - "glob": "dist/cjs/src/bin.js" + "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.17" @@ -5692,7 +5639,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -5701,7 +5647,6 @@ "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, @@ -8293,49 +8238,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rimraf/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/rimraf/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rimraf/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/run-applescript": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", @@ -9827,15 +9729,6 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/package.json b/package.json index b88110b..0143503 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,9 @@ "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { - "@grpc/grpc-js": "^1.9.7", + "@grpc/grpc-js": "^1.9.8", "@grpc/proto-loader": "^0.7.10", - "@mobicoop/configuration-module": "^4.1.0", + "@mobicoop/configuration-module": "^6.1.0", "@mobicoop/ddd-library": "^2.1.1", "@mobicoop/health-module": "^2.3.1", "@mobicoop/message-broker-module": "^2.1.1", @@ -44,8 +44,8 @@ "rimraf": "^5.0.5" }, "devDependencies": { - "@nestjs/cli": "^10.2.0", - "@nestjs/schematics": "^10.0.2", + "@nestjs/cli": "^10.2.1", + "@nestjs/schematics": "^10.0.3", "@nestjs/testing": "^10.2.7", "@types/express": "^4.17.20", "@types/jest": "29.5.6", diff --git a/src/config/carpool.config.ts b/src/config/carpool.config.ts index 226104e..0a30994 100644 --- a/src/config/carpool.config.ts +++ b/src/config/carpool.config.ts @@ -3,6 +3,7 @@ import { Config } from './config'; export interface CarpoolConfig extends Config { departureTimeMargin: number; + recurrentAdValidityDuration: number; role: string; seatsProposed: number; seatsRequested: number; @@ -13,6 +14,9 @@ export default registerAs('carpool', () => ({ departureTimeMargin: process.env.DEPARTURE_TIME_MARGIN ? parseInt(process.env.DEPARTURE_TIME_MARGIN, 10) : 900, + recurrentAdValidityDuration: process.env.RECURRENT_AD_VALIDITY_DURATION + ? parseInt(process.env.RECURRENT_AD_VALIDITY_DURATION, 10) + : 365, role: process.env.ROLE ?? 'passenger', seatsProposed: process.env.SEATS_PROPOSED ? parseInt(process.env.SEATS_PROPOSED, 10) diff --git a/src/config/match.config.ts b/src/config/match.config.ts new file mode 100644 index 0000000..cfa6ab7 --- /dev/null +++ b/src/config/match.config.ts @@ -0,0 +1,40 @@ +import { registerAs } from '@nestjs/config'; +import { Config } from './config'; + +export interface MatchConfig extends Config { + algorithm: string; + remoteness: number; + useProportion: boolean; + proportion: number; + useAzimuth: boolean; + azimuthMargin: number; + maxDetourDistanceRatio: number; + maxDetourDurationRatio: number; +} + +export default registerAs('match', () => ({ + algorithm: process.env.ALGORITHM ?? 'PASSENGER_ORIENTED', + remoteness: process.env.REMOTENESS + ? parseInt(process.env.REMOTENESS, 10) + : 15000, + useProportion: process.env.USE_PROPORTION + ? process.env.USE_PROPORTION === 'false' + ? false + : true + : true, + proportion: process.env.PROPORTION ? parseFloat(process.env.PROPORTION) : 0.3, + useAzimuth: process.env.USE_AZIMUTH + ? process.env.USE_AZIMUTH === 'false' + ? false + : true + : true, + azimuthMargin: process.env.AZIMUTH_MARGIN + ? parseInt(process.env.AZIMUTH_MARGIN, 10) + : 10, + maxDetourDistanceRatio: process.env.MAX_DETOUR_DISTANCE_RATIO + ? parseFloat(process.env.MAX_DETOUR_DISTANCE_RATIO) + : 0.3, + maxDetourDurationRatio: process.env.MAX_DETOUR_DURATION_RATIO + ? parseFloat(process.env.MAX_DETOUR_DURATION_RATIO) + : 0.3, +})); diff --git a/src/modules/configuration/core/application/commands/set-configuration/set-configuration.service.ts b/src/modules/configuration/core/application/commands/set-configuration/set-configuration.service.ts index 18a54b0..d17e483 100644 --- a/src/modules/configuration/core/application/commands/set-configuration/set-configuration.service.ts +++ b/src/modules/configuration/core/application/commands/set-configuration/set-configuration.service.ts @@ -31,7 +31,8 @@ export class SetConfigurationService implements ICommandHandler { ); if (isNaN(value)) throw new ArgumentInvalidException('Bad value'); return await this.configurationRepository.set( - command.configurationIdentifier, + command.configurationIdentifier.domain, + command.configurationIdentifier.key, value, ); } diff --git a/src/modules/configuration/core/application/queries/get-configuration/get-configuration.query-handler.ts b/src/modules/configuration/core/application/queries/get-configuration/get-configuration.query-handler.ts index d32fede..9d47e77 100644 --- a/src/modules/configuration/core/application/queries/get-configuration/get-configuration.query-handler.ts +++ b/src/modules/configuration/core/application/queries/get-configuration/get-configuration.query-handler.ts @@ -17,7 +17,8 @@ export class GetConfigurationQueryHandler implements IQueryHandler { ) {} async execute(query: GetConfigurationQuery): Promise { return await this.configurationRepository.get( - query.configurationIdentifier, + query.configurationIdentifier.domain, + query.configurationIdentifier.key, this.configurationsManager.identifierType(query.configurationIdentifier), ); } diff --git a/src/modules/configuration/core/application/services/configurations-manager.service.ts b/src/modules/configuration/core/application/services/configurations-manager.service.ts index 01d9b6b..0d81099 100644 --- a/src/modules/configuration/core/application/services/configurations-manager.service.ts +++ b/src/modules/configuration/core/application/services/configurations-manager.service.ts @@ -9,6 +9,7 @@ import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { CarpoolConfig } from '@src/config/carpool.config'; import { Config } from '@src/config/config'; +import { MatchConfig } from '@src/config/match.config'; import { PaginationConfig } from '@src/config/pagination.config'; @Injectable() @@ -21,6 +22,10 @@ export class ConfigurationsManagerService { ...(this.configService.get('carpool') as CarpoolConfig), domain: ConfigurationDomain.CARPOOL, }, + { + ...(this.configService.get('match') as MatchConfig), + domain: ConfigurationDomain.MATCH, + }, { ...(this.configService.get( 'pagination', diff --git a/src/modules/configuration/core/application/services/populate.service.ts b/src/modules/configuration/core/application/services/populate.service.ts index 02efb6b..417c994 100644 --- a/src/modules/configuration/core/application/services/populate.service.ts +++ b/src/modules/configuration/core/application/services/populate.service.ts @@ -36,19 +36,15 @@ export class PopulateService implements OnApplicationBootstrap { try { if (key !== 'domain') await this.getConfigurationRepository.get( - { - domain: config.domain, - key, - }, + config.domain, + key, this.configurationsManager.configurationType(configuration[key]), ); } catch (error: any) { if (error instanceof NotFoundException) { this.setConfigurationRepository.set( - { - domain: config.domain, - key, - }, + config.domain, + key, `${configuration[key]}`, ); } diff --git a/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts b/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts index f5c4cbe..9e30e1d 100644 --- a/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts +++ b/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts @@ -20,6 +20,17 @@ const mockConfigService = { seatsRequested: 1, strictFrequency: false, }; + case 'match': + return { + algorithm: 'PASSENGER_ORIENTED', + remoteness: 15000, + useProportion: true, + proportion: 0.3, + useAzimuth: true, + azimuthMargin: 10, + maxDetourDistanceRatio: 0.3, + maxDetourDurationRatio: 0.3, + }; case 'pagination': return { perPage: 10, @@ -53,7 +64,7 @@ describe('Configurations Manager Service', () => { it('should return the list of configuration elements', () => { const list: Config[] = configurationsManagerService.list(); - expect(list).toHaveLength(2); + expect(list).toHaveLength(3); }); describe('identifierType', () => { @@ -68,8 +79,8 @@ describe('Configurations Manager Service', () => { }); it('should throw if configuration item is not found', () => { const configurationIdentifier: ConfigurationIdentifier = { - domain: ConfigurationDomain.CARPOOL, - key: 'minAge', + domain: ConfigurationDomain.MATCH, + key: 'maxDetour', }; expect(() => { configurationsManagerService.identifierType(configurationIdentifier);