mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 03:35:26 +03:00
Be more efficient about getting info
This commit is contained in:
parent
7b649a5a19
commit
318fd70cff
@ -647,9 +647,19 @@ def hourly_timeline():
|
||||
.iterator()
|
||||
)
|
||||
|
||||
count = 0
|
||||
start = 0
|
||||
end = 0
|
||||
hours: dict[str, list[dict[str, any]]] = {}
|
||||
|
||||
for t in timeline:
|
||||
if count == 0:
|
||||
start = t["timestamp"]
|
||||
else:
|
||||
end = t["timestamp"]
|
||||
|
||||
count += 1
|
||||
|
||||
hour = (
|
||||
datetime.fromtimestamp(t["timestamp"]).replace(
|
||||
minute=0, second=0, microsecond=0
|
||||
@ -665,9 +675,9 @@ def hourly_timeline():
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"start": timeline[0].timestamp,
|
||||
"end": timeline[-1].timestamp,
|
||||
"count": timeline.count(),
|
||||
"start": start,
|
||||
"end": end,
|
||||
"count": count,
|
||||
"hours": hours,
|
||||
}
|
||||
)
|
||||
|
||||
@ -23,14 +23,14 @@ export function Review() {
|
||||
}
|
||||
|
||||
const cards: CardsData = {};
|
||||
Object.keys(hourlyTimeline)
|
||||
Object.keys(hourlyTimeline["hours"])
|
||||
.reverse()
|
||||
.forEach((hour) => {
|
||||
const day = new Date(parseInt(hour) * 1000);
|
||||
day.setHours(0, 0, 0, 0);
|
||||
const dayKey = (day.getTime() / 1000).toString();
|
||||
const source_to_types: {[key: string]: string[]} = {};
|
||||
Object.values(hourlyTimeline[hour]).forEach((i) => {
|
||||
Object.values(hourlyTimeline["hours"][hour]).forEach((i) => {
|
||||
const time = new Date(i.timestamp * 1000);
|
||||
time.setSeconds(0);
|
||||
time.setMilliseconds(0);
|
||||
@ -46,7 +46,7 @@ export function Review() {
|
||||
cards[dayKey] = {};
|
||||
}
|
||||
cards[dayKey][hour] = {};
|
||||
Object.values(hourlyTimeline[hour]).forEach((i) => {
|
||||
Object.values(hourlyTimeline["hours"][hour]).forEach((i) => {
|
||||
const time = new Date(i.timestamp * 1000);
|
||||
time.setSeconds(0);
|
||||
time.setMilliseconds(0);
|
||||
|
||||
@ -32,5 +32,8 @@ type Timeline = {
|
||||
}
|
||||
|
||||
type HourlyTimeline = {
|
||||
[key: string]: Timeline[];
|
||||
start: number,
|
||||
end: number,
|
||||
count: number,
|
||||
hours: { [key: string]: Timeline[] };
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user