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",
"version": "1.4.2",
"version": "1.4.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@mobicoop/matcher",
"version": "1.4.2",
"version": "1.4.3",
"license": "AGPL",
"dependencies": {
"@grpc/grpc-js": "^1.9.9",

View File

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

View File

@ -42,6 +42,7 @@ export class MatchQuery extends QueryBase {
private readonly originWaypoint: Waypoint;
routeProvider: RouteProviderPort;
// TODO: remove MatchRequestDto depency (here core domain depends on interface /!\)
constructor(props: MatchRequestDto, routeProvider: RouteProviderPort) {
super();
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 !
*/
createJourneys = (): CandidateEntity => {
this.props.journeys = this.props.driverSchedule
// first we create the journeys
.map((driverScheduleItem: ScheduleItem) =>
this._createJourney(driverScheduleItem),
)
// then we filter the ones with invalid pickups
.filter((journey: Journey) => journey.hasValidPickUp());
try {
this.props.journeys = this.props.driverSchedule
// first we create the journeys
.map((driverScheduleItem: ScheduleItem) =>
this._createJourney(driverScheduleItem),
)
// 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;
};