Skip to content

Commit

Permalink
Add in_progress parameter to /api/events to filter the results. (#5013)
Browse files Browse the repository at this point in the history
* Add in_progress parameter to /api/events to filter the results.

* Change in_progress to default to no filtering, 0 means no in progress, 1 means only in progress.

* Fix code format with black.

* Clear blank line.
  • Loading branch information
sergeknystautas committed Jan 11, 2023
1 parent cb0c5c2 commit 731db8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/docs/integrations/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Events from the database. Accepts the following query string parameters:
| `has_snapshot` | int | Filter to events that have snapshots (0 or 1) |
| `has_clip` | int | Filter to events that have clips (0 or 1) |
| `include_thumbnails` | int | Include thumbnails in the response (0 or 1) |
| `in_progress` | int | Limit to events in progress (0 or 1) |

### `GET /api/events/summary`

Expand Down
4 changes: 4 additions & 0 deletions frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def events():
before = request.args.get("before", type=float)
has_clip = request.args.get("has_clip", type=int)
has_snapshot = request.args.get("has_snapshot", type=int)
in_progress = request.args.get("in_progress", type=int)
include_thumbnails = request.args.get("include_thumbnails", default=1, type=int)
favorites = request.args.get("favorites", type=int)

Expand Down Expand Up @@ -642,6 +643,9 @@ def events():
if not has_snapshot is None:
clauses.append((Event.has_snapshot == has_snapshot))

if not in_progress is None:
clauses.append((Event.end_time.is_null(in_progress)))

if not include_thumbnails:
excluded_fields.append(Event.thumbnail)
else:
Expand Down

0 comments on commit 731db8f

Please sign in to comment.