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

This commit is contained in:
Serge Knystautas 2023-01-08 20:05:51 -08:00
parent 417a42b0b3
commit 6a1ea5e342
2 changed files with 6 additions and 0 deletions

View File

@ -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_snapshot` | int | Filter to events that have snapshots (0 or 1) |
| `has_clip` | int | Filter to events that have clips (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) | | `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` ### `GET /api/events/summary`

View File

@ -565,6 +565,8 @@ def events():
has_clip = request.args.get("has_clip", type=int) has_clip = request.args.get("has_clip", type=int)
has_snapshot = request.args.get("has_snapshot", type=int) has_snapshot = request.args.get("has_snapshot", type=int)
include_thumbnails = request.args.get("include_thumbnails", default=1, type=int) include_thumbnails = request.args.get("include_thumbnails", default=1, type=int)
in_progress = request.args.get("in_progress", default=0, type=int)
favorites = request.args.get("favorites", type=int) favorites = request.args.get("favorites", type=int)
clauses = [] clauses = []
@ -636,6 +638,9 @@ def events():
else: else:
selected_columns.append(Event.thumbnail) selected_columns.append(Event.thumbnail)
if in_progress:
clauses.append((Event.end_time.is_null()))
if favorites: if favorites:
clauses.append((Event.retain_indefinitely == favorites)) clauses.append((Event.retain_indefinitely == favorites))