Skip to content

Handle preparation-time errors separately from other booking errors - #696

Draft
nilspenzel wants to merge 12 commits into
motis-project:masterfrom
nilspenzel:prepTime
Draft

nilspenzel wants to merge 12 commits into
motis-project:masterfrom
nilspenzel:prepTime

Conversation

@nilspenzel

Copy link
Copy Markdown
Contributor

This PR implements a strategy for exiting early when the intended booking is no longer possible due to insufficient preparation time, even though whitelisting was successful.

During whitelisting, we compute for each option the exact point in time until which the request will not be declined due to preparation time. This expiration time is passed through the planAndSign pipeline and added to the signature of the resulting ODM leg.

When the user clicks the button that triggers the call to bookingApi, we check whether the offer has already expired. If it has, we immediately return an error message without counting it as a booking error, avoiding noise in developer alerts.

This also allows us to inform the user when the offer will expire.

There are still two sources of inaccuracy in the computation of the expiration time:

  1. The Date.now() call used for the early-exit check happens earlier than the Date.now() call used for the preparation-time check. I intend to address this by introducing a small buffer (e.g. 30 seconds).

  2. Before this PR, promisedTimes are derived from the leg and are therefore rounded to full minutes by MOTIS. This requires corresponding rounding logic around the preparation-time check causing inaccuracy in the computation of the time the offer will expire.

I intend to address the second point by deriving promisedTimes from the exact values passed through the planAndSign pipeline via tripId instead. This is not yet implemented at the time of creating this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buchungen die kurz vor der Preparation Time valide waren aber danach nicht mehr sollen kein Alert auslösen

1 participant