From a82334ca1cd57bf3517df43552a58947ffcf6209 Mon Sep 17 00:00:00 2001 From: tpjanssen <25168870+tpjanssen@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:52:26 +0200 Subject: [PATCH] API enhancements (#8107) --- docs/docs/integrations/api.md | 2 ++ frigate/http.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/docs/docs/integrations/api.md b/docs/docs/integrations/api.md index 27b760cab..7ddc773c3 100644 --- a/docs/docs/integrations/api.md +++ b/docs/docs/integrations/api.md @@ -172,6 +172,8 @@ Events from the database. Accepts the following query string parameters: | `min_score` | float | Minimum score of the event | | `max_score` | float | Maximum score of the event | | `is_submitted` | int | Filter events that are submitted to Frigate+ (0 or 1) | +| `min_length` | float | Minimum length of the event | +| `max_length` | float | Maximum length of the event | ### `GET /api/timeline` diff --git a/frigate/http.py b/frigate/http.py index 3098285cc..64ba51ea0 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -805,6 +805,8 @@ def events(): min_score = request.args.get("min_score", type=float) max_score = request.args.get("max_score", type=float) is_submitted = request.args.get("is_submitted", type=int) + min_length = request.args.get("min_length", type=float) + max_length = request.args.get("max_length", type=float) clauses = [] @@ -933,6 +935,12 @@ def events(): if min_score is not None: clauses.append((Event.data["score"] >= min_score)) + if min_length is not None: + clauses.append(((Event.end_time - Event.start_time) >= min_length)) + + if max_length is not None: + clauses.append(((Event.end_time - Event.start_time) <= max_length)) + if is_submitted is not None: if is_submitted == 0: clauses.append((Event.plus_id.is_null()))