API enhancements (#8107)

This commit is contained in:
tpjanssen 2023-10-09 15:52:26 +02:00 committed by GitHub
parent d7ddcea951
commit a82334ca1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -172,6 +172,8 @@ Events from the database. Accepts the following query string parameters:
| `min_score` | float | Minimum score of the event | | `min_score` | float | Minimum score of the event |
| `max_score` | float | Maximum 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) | | `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` ### `GET /api/timeline`

View File

@ -805,6 +805,8 @@ def events():
min_score = request.args.get("min_score", type=float) min_score = request.args.get("min_score", type=float)
max_score = request.args.get("max_score", type=float) max_score = request.args.get("max_score", type=float)
is_submitted = request.args.get("is_submitted", type=int) 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 = [] clauses = []
@ -933,6 +935,12 @@ def events():
if min_score is not None: if min_score is not None:
clauses.append((Event.data["score"] >= min_score)) 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 is not None:
if is_submitted == 0: if is_submitted == 0:
clauses.append((Event.plus_id.is_null())) clauses.append((Event.plus_id.is_null()))