Skip to content

Commit

Permalink
🕒 - Take into account ride delay on start (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
planecore authored Mar 9, 2024
1 parent 37cd9ad commit d48c52f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rides/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Scheduler {
throw new NotFoundRouteForRide(logNames.routeApi.getRoutes.failed)
}

if (env === "production" && dayjs().isAfter(route.arrivalTime)) {
if (env === "production" && dayjs(route.arrivalTime).add(route.delay, "minutes").isBefore(dayjs())) {
logger.info(logNames.scheduler.rideInPast, {
date: ride.departureDate,
origin: ride.originId,
Expand All @@ -59,7 +59,7 @@ export class Scheduler {
throw new RideNotInTimeError(logNames.scheduler.rideInPast)
}

if (env === "production" && dayjs(route.departureTime).diff(dayjs(), "minutes") > 60) {
if (env === "production" && dayjs(route.departureTime).add(route.delay, "minutes").diff(dayjs(), "minutes") > 60) {
logger.info(logNames.scheduler.rideInFuture, {
date: ride.departureDate,
origin: ride.originId,
Expand Down

0 comments on commit d48c52f

Please sign in to comment.