Fix same-day flight location tracking
When multiple flights arrived on the same date, location tracking only compared dates and missed later flights. Now compares both date and time to handle same-day connecting flights correctly. Example: Nov 21, 2023 - 06:15: Arrive Madrid (MVD → MAD) - 09:15: Arrive London (MAD → LHR) ← Now properly detected as most recent This ensures users show as "home" when they've returned to UK on the same day as an international connection. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
af492750cb
commit
a92debea5b
2 changed files with 53 additions and 27 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import date, datetime
|
||||
|
||||
import agenda.travel as travel
|
||||
import agenda.trip
|
||||
from web_view import app
|
||||
|
||||
|
|
@ -10,20 +11,30 @@ def test_get_location_for_date() -> None:
|
|||
today = datetime.now().date()
|
||||
start = date(today.year, 1, 1)
|
||||
trips = [
|
||||
t for t in agenda.trip.build_trip_list() if t.start == date(2025, 2, 9)
|
||||
t
|
||||
for t in agenda.trip.build_trip_list()
|
||||
if t.start in [date(2023, 11, 14), date(2025, 2, 9)]
|
||||
]
|
||||
assert len(trips) == 1
|
||||
assert len(trips) == 2
|
||||
|
||||
data_dir = app.config["PERSONAL_DATA"]
|
||||
|
||||
# Parse YAML files once for the test
|
||||
import agenda.travel as travel
|
||||
bookings = travel.parse_yaml("flights", data_dir)
|
||||
accommodations = travel.parse_yaml("accommodation", data_dir)
|
||||
airports = travel.parse_yaml("airports", data_dir)
|
||||
|
||||
l1 = agenda.busy.get_location_for_date(date(2025, 2, 15), trips, bookings, accommodations, airports)
|
||||
l1 = agenda.busy.get_location_for_date(
|
||||
date(2025, 2, 15), trips, bookings, accommodations, airports
|
||||
)
|
||||
assert l1[0] == "Hackettstown"
|
||||
|
||||
l2 = agenda.busy.get_location_for_date(date(2025, 7, 1), trips, bookings, accommodations, airports)
|
||||
l2 = agenda.busy.get_location_for_date(
|
||||
date(2025, 7, 1), trips, bookings, accommodations, airports
|
||||
)
|
||||
assert l2[0] == "Bristol"
|
||||
|
||||
l2 = agenda.busy.get_location_for_date(
|
||||
date(2023, 12, 2), trips, bookings, accommodations, airports
|
||||
)
|
||||
assert l2[0] == "Bristol"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue