Files
TJWaterServerBinary/app/infra/db/postgresql/network_assets.py
T
jiang 5966d039de refactor(backend)!: separate algorithm and data layers
Reorganize algorithm packages by business responsibility, move orchestration into services, and keep database access behind pooled repositories.

Harden analysis API validation, remove unsafe legacy simulation endpoints, and add regression and architecture boundary coverage.

BREAKING CHANGE: legacy algorithm module paths and obsolete simulation endpoints are removed.
2026-09-04 17:30:55 +08:00

28 lines
728 B
Python

"""Read repositories for project network assets."""
from typing import Any
from psycopg import AsyncConnection
class NetworkAssetRepository:
@staticmethod
async def get_pipes_by_ids(
conn: AsyncConnection,
pipe_ids: list[str],
) -> list[dict[str, Any]]:
if not pipe_ids:
return []
async with conn.cursor() as cur:
await cur.execute(
"""
SELECT id, diameter, start_node_id AS node1,
end_node_id AS node2
FROM gis.pipes
WHERE id = ANY(%s)
ORDER BY id
""",
(pipe_ids,),
)
return await cur.fetchall()