Skip to content

Commit

Permalink
Add estimated time remaining to reindexing pane
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye217 committed Oct 11, 2024
1 parent ed5f1e0 commit fe90964
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frigate/embeddings/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def reindex(self) -> None:
"descriptions": 0,
"processed_objects": 0,
"total_objects": 0,
"time_remaining": 0,
}

self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)
Expand Down Expand Up @@ -220,6 +221,13 @@ def reindex(self) -> None:
totals["descriptions"],
)

# Calculate time remaining
elapsed_time = time.time() - st
avg_time_per_event = elapsed_time / totals["processed_objects"]
remaining_events = total_events - totals["processed_objects"]
time_remaining = avg_time_per_event * remaining_events
totals["time_remaining"] = int(time_remaining)

self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)

# Move to the next page
Expand Down
11 changes: 11 additions & 0 deletions web/src/pages/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useTimezone } from "@/hooks/use-date-utils";
import { FrigateConfig } from "@/types/frigateConfig";
import { SearchFilter, SearchQuery, SearchResult } from "@/types/search";
import { ModelState } from "@/types/ws";
import { formatSecondsToDuration } from "@/utils/dateUtil";
import SearchView from "@/views/search/SearchView";
import { useCallback, useEffect, useMemo, useState } from "react";
import { LuCheck, LuExternalLink, LuX } from "react-icons/lu";
Expand Down Expand Up @@ -282,6 +283,16 @@ export default function Explore() {
/>
</div>
<div className="flex w-96 flex-col gap-2 py-5">
{reindexProgress.time_remaining >= 0 && (
<div className="mb-3 flex flex-col items-center justify-center gap-1">
<div className="text-primary-variant">
Estimated time remaining:
</div>
{formatSecondsToDuration(
reindexProgress.time_remaining,
) || "Finishing shortly"}
</div>
)}
<div className="flex flex-row items-center justify-center gap-3">
<span className="text-primary-variant">
Thumbnails embedded:
Expand Down
1 change: 1 addition & 0 deletions web/src/types/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type EmbeddingsReindexProgressType = {
descriptions: number;
processed_objects: number;
total_objects: number;
time_remaining: number;
};

export type ToggleableSetting = "ON" | "OFF";

0 comments on commit fe90964

Please sign in to comment.