From 7b649a5a198eeedd0b4c9ad1dade96d486639726 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 7 Dec 2023 18:19:44 -0700 Subject: [PATCH] Adjust timeline api to include metadata and before --- frigate/http.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frigate/http.py b/frigate/http.py index b9c97b527..e2d61ec0a 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -615,6 +615,7 @@ def timeline(): def hourly_timeline(): """Get hourly summary for timeline.""" camera = request.args.get("camera", "all") + before = request.args.get("before", type=float) limit = request.args.get("limit", 200) tz_name = request.args.get("timezone", default="utc", type=str) _, minute_modifier, _ = get_tz_modifiers(tz_name) @@ -624,6 +625,9 @@ def hourly_timeline(): if camera != "all": clauses.append((Timeline.camera == camera)) + if before: + clauses.append((Timeline.timestamp < before)) + if len(clauses) == 0: clauses.append((True)) @@ -659,7 +663,14 @@ def hourly_timeline(): else: hours[hour].insert(0, t) - return jsonify(hours) + return jsonify( + { + "start": timeline[0].timestamp, + "end": timeline[-1].timestamp, + "count": timeline.count(), + "hours": hours, + } + ) @bp.route("//