Merge branch 'fixEmptyJourneys' into 'main'

Fix empty journeys

See merge request v3/service/matcher!21
This commit is contained in:
Sylvain Briat 2023-11-21 15:15:39 +00:00
commit 59596fadee
4 changed files with 16 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@mobicoop/matcher", "name": "@mobicoop/matcher",
"version": "1.4.2", "version": "1.4.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@mobicoop/matcher", "name": "@mobicoop/matcher",
"version": "1.4.2", "version": "1.4.3",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.9.9", "@grpc/grpc-js": "^1.9.9",

View File

@ -1,6 +1,6 @@
{ {
"name": "@mobicoop/matcher", "name": "@mobicoop/matcher",
"version": "1.4.2", "version": "1.4.3",
"description": "Mobicoop V3 Matcher", "description": "Mobicoop V3 Matcher",
"author": "sbriat", "author": "sbriat",
"private": true, "private": true,

View File

@ -42,6 +42,7 @@ export class MatchQuery extends QueryBase {
private readonly originWaypoint: Waypoint; private readonly originWaypoint: Waypoint;
routeProvider: RouteProviderPort; routeProvider: RouteProviderPort;
// TODO: remove MatchRequestDto depency (here core domain depends on interface /!\)
constructor(props: MatchRequestDto, routeProvider: RouteProviderPort) { constructor(props: MatchRequestDto, routeProvider: RouteProviderPort) {
super(); super();
this.id = props.id; this.id = props.id;

View File

@ -53,13 +53,18 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
* This is a tedious process : additional information can be found in deeper methods ! * This is a tedious process : additional information can be found in deeper methods !
*/ */
createJourneys = (): CandidateEntity => { createJourneys = (): CandidateEntity => {
this.props.journeys = this.props.driverSchedule try {
// first we create the journeys this.props.journeys = this.props.driverSchedule
.map((driverScheduleItem: ScheduleItem) => // first we create the journeys
this._createJourney(driverScheduleItem), .map((driverScheduleItem: ScheduleItem) =>
) this._createJourney(driverScheduleItem),
// then we filter the ones with invalid pickups )
.filter((journey: Journey) => journey.hasValidPickUp()); // then we filter the ones with invalid pickups
.filter((journey: Journey) => journey.hasValidPickUp());
} catch (e) {
// irrelevant journeys fall here
// eg. no available day for the given date range
}
return this; return this;
}; };