mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
allow summary data to be filtered
This commit is contained in:
parent
e7839bfd40
commit
ec84847be7
@ -47,6 +47,20 @@ def is_healthy():
|
|||||||
|
|
||||||
@bp.route('/events/summary')
|
@bp.route('/events/summary')
|
||||||
def 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 = (
|
groups = (
|
||||||
Event
|
Event
|
||||||
.select(
|
.select(
|
||||||
@ -56,6 +70,7 @@ def events_summary():
|
|||||||
Event.zones,
|
Event.zones,
|
||||||
fn.COUNT(Event.id).alias('count')
|
fn.COUNT(Event.id).alias('count')
|
||||||
)
|
)
|
||||||
|
.where(reduce(operator.and_, clauses))
|
||||||
.group_by(
|
.group_by(
|
||||||
Event.camera,
|
Event.camera,
|
||||||
Event.label,
|
Event.label,
|
||||||
|
Loading…
Reference in New Issue
Block a user