Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in_progress parameter to /api/events to filter the results. #5013

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -564,6 +564,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 @@ -631,6 +632,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