Reset saved search stats on reindex (#14280)

This commit is contained in:
Josh Hawkins 2024-10-11 07:59:29 -05:00 committed by GitHub
parent ee8091ba91
commit 2897afce41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@
import base64 import base64
import io import io
import logging import logging
import os
import time import time
from PIL import Image from PIL import Image
@ -10,7 +11,11 @@ from playhouse.shortcuts import model_to_dict
from frigate.comms.inter_process import InterProcessRequestor from frigate.comms.inter_process import InterProcessRequestor
from frigate.config.semantic_search import SemanticSearchConfig from frigate.config.semantic_search import SemanticSearchConfig
from frigate.const import UPDATE_EMBEDDINGS_REINDEX_PROGRESS, UPDATE_MODEL_STATE from frigate.const import (
CONFIG_DIR,
UPDATE_EMBEDDINGS_REINDEX_PROGRESS,
UPDATE_MODEL_STATE,
)
from frigate.db.sqlitevecq import SqliteVecQueueDatabase from frigate.db.sqlitevecq import SqliteVecQueueDatabase
from frigate.models import Event from frigate.models import Event
from frigate.types import ModelStatusTypesEnum from frigate.types import ModelStatusTypesEnum
@ -160,6 +165,10 @@ class Embeddings:
self.db.create_embeddings_tables() self.db.create_embeddings_tables()
logger.debug("Created embeddings tables.") logger.debug("Created embeddings tables.")
# Delete the saved stats file
if os.path.exists(os.path.join(CONFIG_DIR, ".search_stats.json")):
os.remove(os.path.join(CONFIG_DIR, ".search_stats.json"))
st = time.time() st = time.time()
totals = { totals = {
"thumbnails": 0, "thumbnails": 0,