From ec84847be7b79175463f04ad5ae1fa12d1738c70 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sat, 16 Jan 2021 09:26:26 -0600 Subject: [PATCH] allow summary data to be filtered --- frigate/http.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frigate/http.py b/frigate/http.py index 19a7d9e06..f58ead7da 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -47,6 +47,20 @@ def is_healthy(): @bp.route('/events/summary') def events_summary(): + has_clip = request.args.get('has_clip', type=int) + has_snapshot = request.args.get('has_snapshot', type=int) + + clauses = [] + + if not has_clip is None: + clauses.append((Event.has_clip == has_clip)) + + if not has_snapshot is None: + clauses.append((Event.has_snapshot == has_snapshot)) + + if len(clauses) == 0: + clauses.append((1 == 1)) + groups = ( Event .select( @@ -56,6 +70,7 @@ def events_summary(): Event.zones, fn.COUNT(Event.id).alias('count') ) + .where(reduce(operator.and_, clauses)) .group_by( Event.camera, Event.label,