get attached - done and health check done
Some checks failed
checks-impure / test (pull_request) Successful in 29s
checks / test (pull_request) Failing after 3m21s

This commit is contained in:
Georg-Stahn
2023-12-04 21:54:10 +01:00
parent 737fff1c21
commit c1792a7730
3 changed files with 40 additions and 26 deletions

View File

@@ -1,3 +1,5 @@
from sqlalchemy.sql.expression import true
from typing import List, Optional
from sqlalchemy.orm import Session
@@ -142,13 +144,22 @@ def get_entity_by_did(db: Session, did: str) -> Optional[sql_models.Entity]:
def get_attached_entities(
db: Session, skip: int = 0, limit: int = 100
) -> List[sql_models.Entity]:
return db.query(sql_models.Entity).offset(skip).limit(limit).filter(sql_models.Entity.attached is True)
return (
db.query(sql_models.Entity)
.filter(sql_models.Entity.attached == true())
# https://stackoverflow.com/questions/18998010/flake8-complains-on-boolean-comparison-in-filter-clause
.offset(skip)
.limit(limit)
.all()
)
# set attached
# None if did not found
# Returns same entity if setting didnt changed something
def set_attached_by_entity_did(db: Session, entity_did: str, value: bool) -> bool:
# None if did not found
# Returns same entity if setting didnt changed something
def set_attached_by_entity_did(
db: Session, entity_did: str, value: bool
) -> Optional[sql_models.Entity]:
# ste attached to true
db_entity = get_entity_by_did(db, entity_did)
if db_entity is not None: