forked from Github/frigate
new http endpoints
This commit is contained in:
@@ -8,7 +8,7 @@ import cv2
|
||||
import numpy as np
|
||||
from flask import (Blueprint, Flask, Response, current_app, jsonify,
|
||||
make_response, request)
|
||||
from peewee import SqliteDatabase, operator
|
||||
from peewee import SqliteDatabase, operator, fn
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
|
||||
from frigate.models import Event
|
||||
@@ -42,6 +42,25 @@ def create_app(frigate_config, database: SqliteDatabase, camera_metrics, detecto
|
||||
def is_healthy():
|
||||
return "Frigate is running. Alive and healthy!"
|
||||
|
||||
@bp.route('/events/summary')
|
||||
def events_summary():
|
||||
groups = (
|
||||
Event
|
||||
.select(
|
||||
Event.camera,
|
||||
Event.label,
|
||||
fn.strftime('%Y-%m-%d', fn.datetime(Event.start_time, 'unixepoch')).alias('day'),
|
||||
fn.COUNT(Event.id).alias('count')
|
||||
)
|
||||
.group_by(
|
||||
Event.camera,
|
||||
Event.label,
|
||||
fn.strftime('%Y-%m-%d', fn.datetime(Event.start_time, 'unixepoch'))
|
||||
)
|
||||
)
|
||||
|
||||
return jsonify([e for e in groups.dicts()])
|
||||
|
||||
@bp.route('/events')
|
||||
def events():
|
||||
limit = request.args.get('limit', 100)
|
||||
@@ -78,7 +97,11 @@ def events():
|
||||
|
||||
return jsonify([model_to_dict(e) for e in events])
|
||||
|
||||
@bp.route('/debug/stats')
|
||||
@bp.route('/config')
|
||||
def config():
|
||||
return jsonify(current_app.frigate_config.to_dict())
|
||||
|
||||
@bp.route('/stats')
|
||||
def stats():
|
||||
camera_metrics = current_app.camera_metrics
|
||||
stats = {}
|
||||
|
||||
Reference in New Issue
Block a user