Selaa lähdekoodia

fix(proxy): fix TypeError by using sqlalchemy case construct instead of func.case

hujiarui 1 kuukausi sitten
vanhempi
sitoutus
4498b51f72
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      app/services/proxy_reputation_service.py

+ 2 - 2
app/services/proxy_reputation_service.py

@@ -2,7 +2,7 @@ import time
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
 from typing import Optional, Dict, Any, Tuple
 from typing import Optional, Dict, Any, Tuple
 from sqlalchemy.ext.asyncio import AsyncSession
 from sqlalchemy.ext.asyncio import AsyncSession
-from sqlalchemy import select, func, and_
+from sqlalchemy import select, func, and_, case
 
 
 from app.models.proxy_reputation import ProxyReputation, ProxyTelemetryLog
 from app.models.proxy_reputation import ProxyReputation, ProxyTelemetryLog
 from app.schemas.proxy_reputation import (
 from app.schemas.proxy_reputation import (
@@ -82,7 +82,7 @@ class ProxyReputationService:
             select(
             select(
                 func.count(ProxyTelemetryLog.id).label("total_cnt"),
                 func.count(ProxyTelemetryLog.id).label("total_cnt"),
                 func.sum(
                 func.sum(
-                    func.case((ProxyTelemetryLog.success.is_(False), 1), else_=0)
+                    case((ProxyTelemetryLog.success.is_(False), 1), else_=0)
                 ).label("fail_cnt"),
                 ).label("fail_cnt"),
             )
             )
             .where(
             .where(