fix: search for ps by id
This commit is contained in:
@@ -114,22 +114,6 @@ async def get_process_schema_page_DTO(
|
|||||||
limit=limit,
|
limit=limit,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_process_schema_by_title(connection: AsyncConnection, title: str) -> Optional[ProcessSchema]:
|
|
||||||
"""
|
|
||||||
Получает process schema по title.
|
|
||||||
"""
|
|
||||||
query = select(process_schema_table).where(process_schema_table.c.title == title)
|
|
||||||
|
|
||||||
process_schema_db_cursor = await connection.execute(query)
|
|
||||||
|
|
||||||
process_schema_data = process_schema_db_cursor.mappings().one_or_none()
|
|
||||||
if not process_schema_data:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return ProcessSchema.model_validate(process_schema_data)
|
|
||||||
|
|
||||||
|
|
||||||
async def get_process_schema_by_id(connection: AsyncConnection, id: int) -> Optional[ProcessSchema]:
|
async def get_process_schema_by_id(connection: AsyncConnection, id: int) -> Optional[ProcessSchema]:
|
||||||
"""
|
"""
|
||||||
Получает process_schema по id.
|
Получает process_schema по id.
|
||||||
@@ -203,9 +187,9 @@ async def get_last_created_process_schema(connection: AsyncConnection) -> Option
|
|||||||
|
|
||||||
async def create_process_schema(
|
async def create_process_schema(
|
||||||
connection: AsyncConnection, creator_id: int, title: str, description: str
|
connection: AsyncConnection, creator_id: int, title: str, description: str
|
||||||
) -> Optional[ProcessSchema]:
|
) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Создает нове поле в таблице process_schema_table.
|
Создает новое поле в таблице process_schema_table.
|
||||||
"""
|
"""
|
||||||
query = insert(process_schema_table).values(
|
query = insert(process_schema_table).values(
|
||||||
title=title,
|
title=title,
|
||||||
@@ -217,6 +201,7 @@ async def create_process_schema(
|
|||||||
status=ProcessStatus.ACTIVE.value,
|
status=ProcessStatus.ACTIVE.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
await connection.execute(query)
|
result = await connection.execute(query)
|
||||||
|
|
||||||
await connection.commit()
|
await connection.commit()
|
||||||
|
|
||||||
|
return result.lastrowid
|
||||||
|
@@ -42,28 +42,6 @@ async def get_ps_node_by_type_and_ps_id(connection: AsyncConnection, node_type:
|
|||||||
return Ps_Node.model_validate(ps_node_data)
|
return Ps_Node.model_validate(ps_node_data)
|
||||||
|
|
||||||
|
|
||||||
async def create_ps_node_start_schema(
|
|
||||||
connection: AsyncConnection, validated_listen_schema: ListenNodeCoreSchema, creator_id: int
|
|
||||||
) -> Optional[ListenNodeCoreSchema]:
|
|
||||||
"""
|
|
||||||
Создает нове поле в таблице process_schema_table.
|
|
||||||
"""
|
|
||||||
query = insert(ps_node_table).values(
|
|
||||||
ps_id=validated_listen_schema.ps_id,
|
|
||||||
node_type=NodeType.LISTEN.value,
|
|
||||||
settings=validated_listen_schema.data.model_dump(),
|
|
||||||
creator_id=creator_id,
|
|
||||||
created_at=datetime.now(timezone.utc),
|
|
||||||
status=NodeStatus.ACTIVE.value,
|
|
||||||
)
|
|
||||||
|
|
||||||
await connection.execute(query)
|
|
||||||
|
|
||||||
await connection.commit()
|
|
||||||
|
|
||||||
# return validated_listen_schema
|
|
||||||
|
|
||||||
|
|
||||||
async def get_last_ps_node_by_creator_and_ps_id(
|
async def get_last_ps_node_by_creator_and_ps_id(
|
||||||
connection: AsyncConnection, creator_id: int, ps_id: int
|
connection: AsyncConnection, creator_id: int, ps_id: int
|
||||||
) -> Optional[Ps_Node]:
|
) -> Optional[Ps_Node]:
|
||||||
|
@@ -9,7 +9,6 @@ from api.db.logic.account import get_user_by_login
|
|||||||
from api.db.logic.process_schema import (
|
from api.db.logic.process_schema import (
|
||||||
create_process_schema,
|
create_process_schema,
|
||||||
get_process_schema_by_id,
|
get_process_schema_by_id,
|
||||||
get_process_schema_by_title,
|
|
||||||
get_process_schema_page_DTO,
|
get_process_schema_page_DTO,
|
||||||
update_process_schema_by_id,
|
update_process_schema_by_id,
|
||||||
)
|
)
|
||||||
@@ -129,9 +128,9 @@ async def create_processschema_endpoint(
|
|||||||
|
|
||||||
description = "Default description"
|
description = "Default description"
|
||||||
|
|
||||||
await create_process_schema(connection, user_validation.id, title, description)
|
node_id = await create_process_schema(connection, user_validation.id, title, description)
|
||||||
|
|
||||||
process_schema_new = await get_process_schema_by_title(connection, title)
|
process_schema_new = await get_process_schema_by_id(connection, node_id)
|
||||||
|
|
||||||
start_node_data = ListenNodeData(ps_id=process_schema_new.id, node_type=NodeType.START.value, is_start="True")
|
start_node_data = ListenNodeData(ps_id=process_schema_new.id, node_type=NodeType.START.value, is_start="True")
|
||||||
|
|
||||||
@@ -163,7 +162,7 @@ async def create_processschema_endpoint(
|
|||||||
|
|
||||||
await update_process_schema_settings_by_id(connection, process_schema_new.id, settings_dict)
|
await update_process_schema_settings_by_id(connection, process_schema_new.id, settings_dict)
|
||||||
|
|
||||||
process_schema_new = await get_process_schema_by_title(connection, title)
|
process_schema_new = await get_process_schema_by_id(connection, node_id)
|
||||||
|
|
||||||
ps_node_front_response = Ps_NodeFrontResponse(
|
ps_node_front_response = Ps_NodeFrontResponse(
|
||||||
description=node_descriptor.model_dump(),
|
description=node_descriptor.model_dump(),
|
||||||
|
Reference in New Issue
Block a user