fixed bug in the database when assigning a state to a top file
This commit is contained in:
parent
ec89c3b7ac
commit
42a748c6b6
@ -1,6 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import select, delete, and_, bindparam
|
from sqlalchemy import select, delete, and_, or_, bindparam
|
||||||
from sqlalchemy.dialects.postgresql import insert
|
from sqlalchemy.dialects.postgresql import insert
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
@ -136,7 +136,7 @@ def top_state_assign(req: Request, host_name: str, state_name: str):
|
|||||||
path_labels = host_name.replace("%%2F", "%%2f").split("%%2f")
|
path_labels = host_name.replace("%%2F", "%%2f").split("%%2f")
|
||||||
parent_id = None
|
parent_id = None
|
||||||
for path in path_labels:
|
for path in path_labels:
|
||||||
host_stmt = select(Host).where(and_(Host.name == path, Host.parent_id == parent_id))
|
host_stmt = select(Host).where(or_(and_(Host.name == path, Host.parent_id == parent_id, Host.is_hostgroup == True), and_(Host.name == path, Host.is_hostgroup == False, len(path_labels) == 1))) # type: ignore
|
||||||
host_res = db.execute(host_stmt).fetchall()
|
host_res = db.execute(host_stmt).fetchall()
|
||||||
|
|
||||||
if len(host_res) != 1:
|
if len(host_res) != 1:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user