diff --git a/frigate/http.py b/frigate/http.py index 380cf7c83..f3e97f944 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -468,26 +468,17 @@ def recordings(camera_name): date = f"{search.group(1)}-{search.group(2)}" if date not in dates: dates[date] = OrderedDict() - dates[date][search.group(3)] = 0 + dates[date][search.group(3)] = [] - events = ( - Event.select( - fn.DATE(Event.start_time, "unixepoch", "localtime"), - fn.STRFTIME("%H", Event.start_time, "unixepoch", "localtime"), - fn.COUNT(Event.id), - ) - .where(Event.camera == camera_name) - .group_by( - fn.DATE(Event.start_time, "unixepoch", "localtime"), - fn.STRFTIME("%H", Event.start_time, "unixepoch", "localtime"), - ) - .tuples() - ) + events = Event.select().where(Event.camera == camera_name) - for date, hour, count in events: + e: Event + for e in events: + date = datetime.fromtimestamp(e.start_time) key = date.strftime("%Y-%m-%d") + hour = date.strftime("%H") if key in dates and hour in dates[key]: - dates[key][hour] = count + dates[key][hour].append(model_to_dict(e, exclude=[Event.thumbnail])) return jsonify( [ diff --git a/web/src/App.jsx b/web/src/App.jsx index 85e466faf..df8516ca4 100644 --- a/web/src/App.jsx +++ b/web/src/App.jsx @@ -29,7 +29,7 @@ export default function App() { - + diff --git a/web/src/components/EventCard.jsx b/web/src/components/EventCard.jsx new file mode 100644 index 000000000..549b5deb7 --- /dev/null +++ b/web/src/components/EventCard.jsx @@ -0,0 +1,38 @@ +import { h } from 'preact'; +import { differenceInSeconds, fromUnixTime, format, startOfHour } from 'date-fns'; +import Link from '../components/Link'; +import { useApiHost } from '../api'; + +export default function EventCard({ camera, event }) { + const apiHost = useApiHost(); + const start = fromUnixTime(event.start_time); + const end = fromUnixTime(event.end_time); + const seconds = Math.max(differenceInSeconds(start, startOfHour(start)) - 10, 0); + return ( + +
+
+ +
+
+
+
{event.label}
+
{(event.top_score * 100).toFixed(1)}%
+
+ + {format(start, 'HH:mm:ss')} - {format(end, 'HH:mm:ss')} + +
+
+
+
+
+ {event.zones.map((zone) => ( +
{zone}
+ ))} +
+
+
+ + ); +} diff --git a/web/src/components/RecordingPlaylist.jsx b/web/src/components/RecordingPlaylist.jsx index 466d2f47a..8aaae08e2 100644 --- a/web/src/components/RecordingPlaylist.jsx +++ b/web/src/components/RecordingPlaylist.jsx @@ -2,6 +2,7 @@ import { h } from 'preact'; import { useState } from 'preact/hooks'; import { format, parseISO } from 'date-fns'; import Accordion from '../components/Accordion'; +import EventCard from '../components/EventCard'; import Link from '../components/Link'; import Menu from '../icons/Menu'; import MenuOpen from '../icons/MenuOpen'; @@ -16,11 +17,16 @@ export default function RecordingPlaylist({ camera, recordings, selectedDate }) result.push( {recording.recordings.map((item) => ( -
- - {item.hour}:00 - - {item.events} Events +
+
+ + {item.hour}:00 + + {item.events.length} Events +
+ {item.events.map((event) => ( + + ))}
))} @@ -30,7 +36,7 @@ export default function RecordingPlaylist({ camera, recordings, selectedDate }) const openClass = active ? '-left-6' : 'right-0'; return ( -
+