fix crash when no date is available in recurrent for a journey
This commit is contained in:
		
							parent
							
								
									f21fa0e9b0
								
							
						
					
					
						commit
						970260f0d2
					
				| 
						 | 
					@ -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;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,7 @@ 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 => {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
      this.props.journeys = this.props.driverSchedule
 | 
					      this.props.journeys = this.props.driverSchedule
 | 
				
			||||||
        // first we create the journeys
 | 
					        // first we create the journeys
 | 
				
			||||||
        .map((driverScheduleItem: ScheduleItem) =>
 | 
					        .map((driverScheduleItem: ScheduleItem) =>
 | 
				
			||||||
| 
						 | 
					@ -60,6 +61,10 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        // then we filter the ones with invalid pickups
 | 
					        // then we filter the ones with invalid pickups
 | 
				
			||||||
        .filter((journey: Journey) => journey.hasValidPickUp());
 | 
					        .filter((journey: Journey) => journey.hasValidPickUp());
 | 
				
			||||||
 | 
					    } catch (e) {
 | 
				
			||||||
 | 
					      // irrelevant journeys fall here
 | 
				
			||||||
 | 
					      // eg. no available day for the given date range
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return this;
 | 
					    return this;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue