mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-17 23:09:35 +00:00
fix(dealix): lazy imports in executive_roi_service to fix CI test collection
- Move heavy service/model imports inside methods to avoid module-level import chains that could fail during pytest collection (saudi_compliance_matrix, contradiction_engine, StrategicDeal, EvidencePack) - Remove unused import (list_integration_connectors) from connector_governance API - Fix StrategicDeal.status query: use notin_(closed_won/closed_lost) instead of == "active" which is not a valid DealStatus enum value https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
This commit is contained in:
parent
f5c5aafbb0
commit
2421e41e7a
@ -8,7 +8,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||||||
|
|
||||||
from app.database import get_db
|
from app.database import get_db
|
||||||
from app.services.connector_governance import connector_governance
|
from app.services.connector_governance import connector_governance
|
||||||
from app.services.operations_hub import list_integration_connectors
|
|
||||||
|
|
||||||
router = APIRouter(prefix="/connectors", tags=["Connector Governance"])
|
router = APIRouter(prefix="/connectors", tags=["Connector Governance"])
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||||||
|
|
||||||
from app.models.deal import Deal
|
from app.models.deal import Deal
|
||||||
from app.models.operations import ApprovalRequest, IntegrationSyncState
|
from app.models.operations import ApprovalRequest, IntegrationSyncState
|
||||||
from app.models.strategic_deal import StrategicDeal
|
|
||||||
from app.models.evidence_pack import EvidencePack, EvidencePackStatus
|
|
||||||
from app.services.saudi_compliance_matrix import saudi_compliance_matrix
|
|
||||||
from app.services.contradiction_engine import contradiction_engine
|
|
||||||
|
|
||||||
|
|
||||||
class ExecutiveRoomService:
|
class ExecutiveRoomService:
|
||||||
@ -104,6 +100,7 @@ class ExecutiveRoomService:
|
|||||||
# ── Compliance ───────────────────────────────────────────
|
# ── Compliance ───────────────────────────────────────────
|
||||||
|
|
||||||
async def _compliance(self, db: AsyncSession, tenant_id: str) -> Dict[str, Any]:
|
async def _compliance(self, db: AsyncSession, tenant_id: str) -> Dict[str, Any]:
|
||||||
|
from app.services.saudi_compliance_matrix import saudi_compliance_matrix
|
||||||
p = await saudi_compliance_matrix.get_posture(db, tenant_id=tenant_id)
|
p = await saudi_compliance_matrix.get_posture(db, tenant_id=tenant_id)
|
||||||
return {
|
return {
|
||||||
"compliant": p.get("compliant", 0),
|
"compliant": p.get("compliant", 0),
|
||||||
@ -115,22 +112,24 @@ class ExecutiveRoomService:
|
|||||||
# ── Contradictions ───────────────────────────────────────
|
# ── Contradictions ───────────────────────────────────────
|
||||||
|
|
||||||
async def _contradictions(self, db: AsyncSession, tenant_id: str) -> Dict[str, Any]:
|
async def _contradictions(self, db: AsyncSession, tenant_id: str) -> Dict[str, Any]:
|
||||||
|
from app.services.contradiction_engine import contradiction_engine
|
||||||
s = await contradiction_engine.get_stats(db, tenant_id=tenant_id)
|
s = await contradiction_engine.get_stats(db, tenant_id=tenant_id)
|
||||||
return {"active": s.get("active", 0), "critical": s.get("critical_active", 0)}
|
return {"active": s.get("active", 0), "critical": s.get("critical_active", 0)}
|
||||||
|
|
||||||
# ── Strategic Deals ──────────────────────────────────────
|
# ── Strategic Deals ──────────────────────────────────────
|
||||||
|
|
||||||
async def _strategic_deals(self, db: AsyncSession, tid: UUID) -> Dict[str, Any]:
|
async def _strategic_deals(self, db: AsyncSession, tid: UUID) -> Dict[str, Any]:
|
||||||
|
from app.models.strategic_deal import StrategicDeal
|
||||||
active = int(
|
active = int(
|
||||||
(await db.execute(
|
(await db.execute(
|
||||||
select(func.count()).select_from(StrategicDeal)
|
select(func.count()).select_from(StrategicDeal)
|
||||||
.where(StrategicDeal.tenant_id == tid, StrategicDeal.status == "active")
|
.where(StrategicDeal.tenant_id == tid, StrategicDeal.status.notin_(["closed_won", "closed_lost"]))
|
||||||
)).scalar() or 0
|
)).scalar() or 0
|
||||||
)
|
)
|
||||||
value = float(
|
value = float(
|
||||||
(await db.execute(
|
(await db.execute(
|
||||||
select(func.coalesce(func.sum(StrategicDeal.estimated_value_sar), 0))
|
select(func.coalesce(func.sum(StrategicDeal.estimated_value_sar), 0))
|
||||||
.where(StrategicDeal.tenant_id == tid, StrategicDeal.status == "active")
|
.where(StrategicDeal.tenant_id == tid, StrategicDeal.status.notin_(["closed_won", "closed_lost"]))
|
||||||
)).scalar() or 0
|
)).scalar() or 0
|
||||||
)
|
)
|
||||||
return {"active": active, "pipeline_value": value}
|
return {"active": active, "pipeline_value": value}
|
||||||
@ -138,6 +137,7 @@ class ExecutiveRoomService:
|
|||||||
# ── Evidence Packs ───────────────────────────────────────
|
# ── Evidence Packs ───────────────────────────────────────
|
||||||
|
|
||||||
async def _evidence_packs(self, db: AsyncSession, tid: UUID) -> Dict[str, Any]:
|
async def _evidence_packs(self, db: AsyncSession, tid: UUID) -> Dict[str, Any]:
|
||||||
|
from app.models.evidence_pack import EvidencePack, EvidencePackStatus
|
||||||
ready = int(
|
ready = int(
|
||||||
(await db.execute(
|
(await db.execute(
|
||||||
select(func.count()).select_from(EvidencePack)
|
select(func.count()).select_from(EvidencePack)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user