-
Notifications
You must be signed in to change notification settings - Fork 0
Examples of Substantial Implementation
File: src/services/claimEstimator.ts
This flow computes the amount of compensation the user can receive according to the APPR Canadian flight compensation regulations.
-
It fetches flight data from our PostgreSQL database directly instead of getting it from an external API.
-
It figures out the final arrival delay by checking the scheduled and actual arrival times.
-
It specifies the compensation amount according to the official APPR regulations by taking into account the airline size (large or small) and the flight delay duration.
-
This regulation indicates that even though there are connecting flights, the delay is to be measured at the final destination which is the demand of Canadian law.
Related core functions:
- calculateFinalArrivalDelayHours()
- apprDomesticCompensationFromHours()
- airlineSizeFromCode()
- estimateApprDomestic()
File: src/services/delayService.ts This module analyzes a user’s complete flight itinerary to determine how much later they arrive at the final destination.
-
It does not rely on any outside services but works with flight timestamps in the database.
-
It processes connecting flights by adding delays cumulatively (for example if Flight A’s delay causes you to miss Flight B, the total delay is calculated at the final arrival of Flight C).
-
This reasoning is applied to the compensation rules therefore ensuring correctness for itineraries with several segments.
Related core functions:
- calculateFinalArrivalDelay()
- calculateCompensationForItinerary()
Files:
- src/jobs/flight-cleanup-job.ts
- src/services/flight-cleanup.ts
We put in place a system of automatic background jobs that would allow the database to be cleaned and updated regularly.
-
Every day, the cleanup service operates and eliminates old flights (flights that have actual arrival dates beyond the set threshold).
-
As a result, it not only prevents the accumulation of unnecessary data but also makes sure that only pertinent flight records are kept for initiating compensation checks.
-
The jobs that are associated with this process are scheduled and executed automatically without depending on the APIs of any third parties.
- Our logic follows specific business rules:
-Delay < 3 hours → no compensation
-Delay between 3–6 hours → partial compensation
-Delay ≥ 9 hours → maximum compensation
-
Compensation values differ by airline size (large vs small)
-
All calculations are based on validated flight data that is obtained directly from our database. This guarantees the reliability of the data and the non-reliance on API responses.