Skip to content

fix: correct airport last visit date and add next visit#640

Open
jonlarson13 wants to merge 6 commits into
johanohly:mainfrom
jonlarson13:main
Open

fix: correct airport last visit date and add next visit#640
jonlarson13 wants to merge 6 commits into
johanohly:mainfrom
jonlarson13:main

Conversation

@jonlarson13

@jonlarson13 jonlarson13 commented Jul 2, 2026

Copy link
Copy Markdown

Summary

  • The airport stats card picked the flight with the max date across all related flights, so a future booked flight (e.g. a trip next month) could be shown as the "last visit" instead of the actual most recent past visit.
  • last visit now only considers flights whose actual arrival/departure time at that airport has already passed.
  • Added a next visit label that surfaces the nearest upcoming flight to that airport, when one exists.

Test plan

  • Review an airport with both upcoming and past flights — both "last visit" and "next visit" labels should be displayed.
  • Review an airport with only an upcoming flight — only the "next visit" label should be displayed.
  • Review an airport with only past flights (no upcoming) — only the "last visit" label should be displayed.

Note

Fix airport last visit date and add next visit label in AirportStatsCard

  • Replaces the single last-visit derivation in AirportStatsCard.svelte with a getVisitSummary util that scans flights for arrivals/departures, resolves times from actual or scheduled data with timezone awareness, and returns both lastVisitLabel and nextVisitLabel.
  • The card now conditionally renders both labels when available, or just one inline with metrics when only one is present.
  • Timer logic is lifted out of AirportTimeCard.svelte into AirportDetailsBody.svelte, which now owns a 30-second ticking now and passes it down to both child components.
  • Behavioral Change: AirportStatsCard and AirportTimeCard now require a now: Date prop from their parent instead of managing time internally.

Macroscope summarized 5ffc36a.

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.
@github-actions github-actions Bot added the Web label Jul 2, 2026
@jonlarson13

Copy link
Copy Markdown
Author

Feature discussion in #639

Comment thread src/lib/components/airport-details/AirportStatsCard.svelte Outdated
Comment thread src/lib/components/airport-details/AirportStatsCard.svelte
@sonarqubecloud

Copy link
Copy Markdown


for (const [matches, actual, scheduled, tz] of touches) {
if (!matches) continue;
const exact =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants