fix crash when no date is available in recurrent for a journey

This commit is contained in:
Sylvain Briat 2023-11-21 16:10:19 +01:00
parent f21fa0e9b0
commit 970260f0d2
2 changed files with 13 additions and 7 deletions

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,6 +53,7 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
* This is a tedious process : additional information can be found in deeper methods !
*/
createJourneys = (): CandidateEntity => {
try {
this.props.journeys = this.props.driverSchedule
// first we create the journeys
.map((driverScheduleItem: ScheduleItem) =>
@ -60,6 +61,10 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
)
// 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;
};