Przeglądaj źródła

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

hujiarui 1 miesiąc temu
rodzic
commit
4498b51f72
1 zmienionych plików z 2 dodań i 2 usunięć
  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 typing import Optional, Dict, Any, Tuple
 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.schemas.proxy_reputation import (
@@ -82,7 +82,7 @@ class ProxyReputationService:
             select(
                 func.count(ProxyTelemetryLog.id).label("total_cnt"),
                 func.sum(
-                    func.case((ProxyTelemetryLog.success.is_(False), 1), else_=0)
+                    case((ProxyTelemetryLog.success.is_(False), 1), else_=0)
                 ).label("fail_cnt"),
             )
             .where(