From 1ccc83a64e0f19eef4ec97ac4b94031b717e588b Mon Sep 17 00:00:00 2001 From: tocmo0nlord Date: Sat, 14 Mar 2026 05:16:31 +0000 Subject: [PATCH] fix: detect flights via stop-to-stop speed (catches gaps with no activity segment) --- work_trace/wizards/wt_import_timeline_wizard.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/work_trace/wizards/wt_import_timeline_wizard.py b/work_trace/wizards/wt_import_timeline_wizard.py index 49d9a3f5..01016674 100644 --- a/work_trace/wizards/wt_import_timeline_wizard.py +++ b/work_trace/wizards/wt_import_timeline_wizard.py @@ -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')