From 67449c30473eb2496485b943872815899976c087 Mon Sep 17 00:00:00 2001 From: tocmo0nlord Date: Sat, 14 Mar 2026 05:08:16 +0000 Subject: [PATCH] fix: require >= 30 min duration for flying classification --- work_trace/wizards/wt_import_timeline_wizard.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/work_trace/wizards/wt_import_timeline_wizard.py b/work_trace/wizards/wt_import_timeline_wizard.py index 689d77c9..49d9a3f5 100644 --- a/work_trace/wizards/wt_import_timeline_wizard.py +++ b/work_trace/wizards/wt_import_timeline_wizard.py @@ -114,7 +114,8 @@ def _max_speed_from_path(timeline_path): return max_speed -MIN_FLIGHT_DISTANCE_MILES = 50 # Shorter than this cannot be a flight +MIN_FLIGHT_DISTANCE_MILES = 50 # Shorter than this cannot be a flight +MIN_FLIGHT_DURATION_HOURS = 0.5 # Less than 30 minutes cannot be a flight def _speed_from_activity_segment(activity, seg_start_ts, seg_end_ts): """Detect flights from an activity segment's start/end coords and timestamps. @@ -140,7 +141,7 @@ def _speed_from_activity_segment(activity, seg_start_ts, seg_end_ts): return 0.0, 0.0 dist_miles = _haversine_miles(slat, slng, elat, elng) speed = dist_miles / dt_hours - return dist_miles, speed + return dist_miles, speed, dt_hours class WtImportTimelineWizard(models.TransientModel): @@ -310,8 +311,10 @@ class WtImportTimelineWizard(models.TransientModel): # to rule out GPS drift (short jumps can look fast due to imprecise timestamps) seg_start = _parse_ts(seg.get('startTime')) seg_end = _parse_ts(seg.get('endTime')) - dist, speed = _speed_from_activity_segment(activity, seg_start, seg_end) - if dist >= MIN_FLIGHT_DISTANCE_MILES and speed > 150: + dist, speed, dt_hours = _speed_from_activity_segment(activity, seg_start, seg_end) + if (dist >= MIN_FLIGHT_DISTANCE_MILES + and speed > 150 + and dt_hours >= MIN_FLIGHT_DURATION_HOURS): pending_mode = 'flying' continue