fix: detect flights via stop-to-stop speed (catches gaps with no activity segment)
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
2026-03-14 05:16:31 +00:00
parent 67449c3047
commit 1ccc83a64e

View File

@@ -230,6 +230,19 @@ class WtImportTimelineWizard(models.TransientModel):
stop['distance_from_previous'] = 0.0
stop['travel_time_from_previous'] = 0.0
# Post-processing: reclassify likely flights using stop-to-stop speed.
# Many flights have no activity segment or timelinePath data — Google just
# records a large gap between two distant visits. We catch those here.
for stop in stops[1:]:
dist = stop.get('distance_from_previous', 0.0)
tt = stop.get('travel_time_from_previous', 0.0)
if (dist >= MIN_FLIGHT_DISTANCE_MILES
and tt >= MIN_FLIGHT_DURATION_HOURS
and tt > 0):
implied_speed = dist / tt
if implied_speed > 150:
stop['travel_mode'] = 'flying'
LocationLog = self.env['wt.location.log']
existing = set(
r.arrived_at.strftime('%Y-%m-%d %H:%M:%S')