mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Allow empty description for tracked objects (#14271)
* Allow tracked object description to be saved as an empty string * ensure event_ids is passed as list
This commit is contained in:
parent
54eb03d2a1
commit
8d753f821d
@ -11,9 +11,7 @@ class EventsSubLabelBody(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class EventsDescriptionBody(BaseModel):
|
class EventsDescriptionBody(BaseModel):
|
||||||
description: Union[str, None] = Field(
|
description: Union[str, None] = Field(title="The description of the event")
|
||||||
title="The description of the event", min_length=1
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EventsCreateBody(BaseModel):
|
class EventsCreateBody(BaseModel):
|
||||||
|
@ -927,27 +927,19 @@ def set_description(
|
|||||||
|
|
||||||
new_description = body.description
|
new_description = body.description
|
||||||
|
|
||||||
if new_description is None or len(new_description) == 0:
|
|
||||||
return JSONResponse(
|
|
||||||
content=(
|
|
||||||
{
|
|
||||||
"success": False,
|
|
||||||
"message": "description cannot be empty",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
status_code=400,
|
|
||||||
)
|
|
||||||
|
|
||||||
event.data["description"] = new_description
|
event.data["description"] = new_description
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
# If semantic search is enabled, update the index
|
# If semantic search is enabled, update the index
|
||||||
if request.app.frigate_config.semantic_search.enabled:
|
if request.app.frigate_config.semantic_search.enabled:
|
||||||
context: EmbeddingsContext = request.app.embeddings
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
context.update_description(
|
if len(new_description) > 0:
|
||||||
event_id,
|
context.update_description(
|
||||||
new_description,
|
event_id,
|
||||||
)
|
new_description,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
context.db.delete_embeddings_description(event_ids=[event_id])
|
||||||
|
|
||||||
response_message = (
|
response_message = (
|
||||||
f"Event {event_id} description is now blank"
|
f"Event {event_id} description is now blank"
|
||||||
@ -1033,8 +1025,8 @@ def delete_event(request: Request, event_id: str):
|
|||||||
# If semantic search is enabled, update the index
|
# If semantic search is enabled, update the index
|
||||||
if request.app.frigate_config.semantic_search.enabled:
|
if request.app.frigate_config.semantic_search.enabled:
|
||||||
context: EmbeddingsContext = request.app.embeddings
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
context.db.delete_embeddings_thumbnail(id=[event_id])
|
context.db.delete_embeddings_thumbnail(event_ids=[event_id])
|
||||||
context.db.delete_embeddings_description(id=[event_id])
|
context.db.delete_embeddings_description(event_ids=[event_id])
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=({"success": True, "message": "Event " + event_id + " deleted"}),
|
content=({"success": True, "message": "Event " + event_id + " deleted"}),
|
||||||
status_code=200,
|
status_code=200,
|
||||||
|
@ -229,8 +229,8 @@ class EventCleanup(threading.Thread):
|
|||||||
Event.delete().where(Event.id << chunk).execute()
|
Event.delete().where(Event.id << chunk).execute()
|
||||||
|
|
||||||
if self.config.semantic_search.enabled:
|
if self.config.semantic_search.enabled:
|
||||||
self.db.delete_embeddings_description(chunk)
|
self.db.delete_embeddings_description(event_ids=[chunk])
|
||||||
self.db.delete_embeddings_thumbnail(chunk)
|
self.db.delete_embeddings_thumbnail(event_ids=[chunk])
|
||||||
logger.debug(f"Deleted {len(events_to_delete)} embeddings")
|
logger.debug(f"Deleted {len(events_to_delete)} embeddings")
|
||||||
|
|
||||||
logger.info("Exiting event cleanup...")
|
logger.info("Exiting event cleanup...")
|
||||||
|
Loading…
Reference in New Issue
Block a user