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')