feat(scada): add calibrated monitoring and incident recovery
This commit is contained in:
@@ -7,6 +7,29 @@ from uuid import UUID
|
||||
from sqlalchemy import text
|
||||
|
||||
|
||||
async def discover_project_ids() -> tuple[str, ...]:
|
||||
"""Return every active PostgreSQL-backed project from authoritative metadata."""
|
||||
from sqlalchemy import select
|
||||
from app.infra.db.metadb.database import SessionLocal
|
||||
from app.infra.db.metadb import models
|
||||
|
||||
async with SessionLocal() as session:
|
||||
rows = await session.scalars(
|
||||
select(models.Project.id)
|
||||
.join(
|
||||
models.ProjectDatabase,
|
||||
models.ProjectDatabase.project_id == models.Project.id,
|
||||
)
|
||||
.where(
|
||||
models.Project.status == "active",
|
||||
models.ProjectDatabase.db_role == "biz_data",
|
||||
models.ProjectDatabase.db_type == "postgresql",
|
||||
)
|
||||
.order_by(models.Project.id)
|
||||
)
|
||||
return tuple(str(project_id) for project_id in rows.all())
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def queue_repository(project_id):
|
||||
"""Resolve the current project route and open its calculation queue."""
|
||||
|
||||
Reference in New Issue
Block a user