From c36b95e0417d6517cc5fd68abf4b44dff28c6149 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Thu, 14 May 2026 17:11:11 +0200 Subject: [PATCH] segments detect: add --fresh flag to clear efforts before re-detecting --- bincio/segments/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bincio/segments/cli.py b/bincio/segments/cli.py index 18f22ef..b5fcac8 100644 --- a/bincio/segments/cli.py +++ b/bincio/segments/cli.py @@ -24,7 +24,8 @@ def segments_group() -> None: @click.option("--handle", required=True, help="User handle to run detection for") @click.option("--activity-id", default=None, help="Limit to a single activity ID (optional)") @click.option("--segment-id", default=None, help="Limit to a single segment ID (optional)") -def detect_cmd(data_dir: str, handle: str, activity_id: str | None, segment_id: str | None) -> None: +@click.option("--fresh", is_flag=True, default=False, help="Clear existing efforts before detecting") +def detect_cmd(data_dir: str, handle: str, activity_id: str | None, segment_id: str | None, fresh: bool) -> None: """Retroactively detect segment efforts for stored activities. Walks every activity with GPS data, runs the detection algorithm against @@ -55,6 +56,11 @@ def detect_cmd(data_dir: str, handle: str, activity_id: str | None, segment_id: click.echo("No segments defined.", err=True) sys.exit(0) + if fresh: + for seg in segments: + _store.save_efforts(dd, handle, seg.id, []) + click.echo(f"Cleared existing efforts for {len(segments)} segment(s).") + # Choose which activities to process. if activity_id: detail_files = [acts_dir / f"{activity_id}.json"]