fix: correct airport last visit date and add next visit#640
fix: correct airport last visit date and add next visit#640jonlarson13 wants to merge 6 commits into
Conversation
The airport stats card picked the flight with the max date across all related flights, so a future booked flight could show up as "last visit". Now last visit only considers flights whose actual arrival or departure time at that airport is in the past, and a new "next visit" line surfaces the nearest upcoming flight to that airport.
|
Feature discussion in #639 |
|
|
|
||
| for (const [matches, actual, scheduled, tz] of touches) { | ||
| if (!matches) continue; | ||
| const exact = |
There was a problem hiding this comment.
🟡 Medium airport-details/AirportStatsCard.svelte:48
When an arrival-side visit has no arrival or arrivalScheduled, getVisitSummary falls back to getFlightDateRange(flight.raw.date, …) and localizes it using the destination timezone. flight.raw.date is the flight's departure date, not its arrival date, so for a red-eye or cross-timezone flight the computed visit is localized to the wrong calendar day. This produces an incorrect last visit or next visit label whenever the arrival falls on a different date than the departure in the destination timezone. Consider using an arrival-derived date (or excluding arrival-side visits that lack arrival timing) so the fallback does not localize the departure date against the destination timezone.
🤖 Copy this AI Prompt to have your agent fix this:
In file @src/lib/components/airport-details/AirportStatsCard.svelte around line 48:
When an arrival-side visit has no `arrival` or `arrivalScheduled`, `getVisitSummary` falls back to `getFlightDateRange(flight.raw.date, …)` and localizes it using the destination timezone. `flight.raw.date` is the flight's departure date, not its arrival date, so for a red-eye or cross-timezone flight the computed visit is localized to the wrong calendar day. This produces an incorrect `last visit` or `next visit` label whenever the arrival falls on a different date than the departure in the destination timezone. Consider using an arrival-derived date (or excluding arrival-side visits that lack arrival timing) so the fallback does not localize the departure date against the destination timezone.



Summary
last visitnow only considers flights whose actual arrival/departure time at that airport has already passed.next visitlabel that surfaces the nearest upcoming flight to that airport, when one exists.Test plan
Note
Fix airport last visit date and add next visit label in AirportStatsCard
AirportStatsCard.sveltewith agetVisitSummaryutil that scans flights for arrivals/departures, resolves times from actual or scheduled data with timezone awareness, and returns bothlastVisitLabelandnextVisitLabel.AirportTimeCard.svelteintoAirportDetailsBody.svelte, which now owns a 30-second tickingnowand passes it down to both child components.AirportStatsCardandAirportTimeCardnow require anow: Dateprop from their parent instead of managing time internally.Macroscope summarized 5ffc36a.