From 5ca5200f1a7dcf259ee379b94c295de6be155915 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Thu, 2 Nov 2023 17:13:16 +0100 Subject: [PATCH] fix journey value object : useless driver neutral target for passenger start --- .../value-objects/journey.value-object.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/modules/ad/core/domain/value-objects/journey.value-object.ts b/src/modules/ad/core/domain/value-objects/journey.value-object.ts index d36bc9e..836aed9 100644 --- a/src/modules/ad/core/domain/value-objects/journey.value-object.ts +++ b/src/modules/ad/core/domain/value-objects/journey.value-object.ts @@ -38,24 +38,22 @@ export class Journey extends ValueObject { actorTime.target == Target.START, ) as ActorTime, ) as JourneyItem; - const passengerDepartureActorTime = + const passengerDepartureActorTime: ActorTime = passengerDepartureJourneyItem.actorTimes.find( (actorTime: ActorTime) => actorTime.role == Role.PASSENGER && actorTime.target == Target.START, ) as ActorTime; - const driverNeutralActorTime = - passengerDepartureJourneyItem.actorTimes.find( - (actorTime: ActorTime) => - actorTime.role == Role.DRIVER && actorTime.target == Target.NEUTRAL, - ) as ActorTime; + const driverActorTime = passengerDepartureJourneyItem.actorTimes.find( + (actorTime: ActorTime) => actorTime.role == Role.DRIVER, + ) as ActorTime; return ( (passengerDepartureActorTime.firstMinDatetime <= - driverNeutralActorTime.firstMaxDatetime && - driverNeutralActorTime.firstMaxDatetime <= + driverActorTime.firstMaxDatetime && + driverActorTime.firstMaxDatetime <= passengerDepartureActorTime.firstMaxDatetime) || (passengerDepartureActorTime.firstMinDatetime <= - driverNeutralActorTime.firstMinDatetime && - driverNeutralActorTime.firstMinDatetime <= + driverActorTime.firstMinDatetime && + driverActorTime.firstMinDatetime <= passengerDepartureActorTime.firstMaxDatetime) ); };