Skip to content

Commit

Permalink
refactor: optimize facet deletion query to use select and improve res…
Browse files Browse the repository at this point in the history
…ult handling
  • Loading branch information
skynetigor committed Jan 15, 2025
1 parent 5ba0b0c commit 8e2f7fd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions keep/api/core/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ def delete_facet(tenant_id: str, facet_id: str) -> bool:
bool: True if the facet was successfully deleted, False otherwise.
"""
with Session(engine) as session:
facet = (
session.query(Facet)
.filter(Facet.tenant_id == tenant_id)
.filter(Facet.id == UUID(facet_id))
.first()
)
facet = session.exec(
select(Facet)
.where(Facet.tenant_id == tenant_id)
.where(Facet.id == UUID(facet_id))
).first()[0] # result returned as tuple
if facet:
session.delete(facet)
session.commit()
Expand Down

0 comments on commit 8e2f7fd

Please sign in to comment.