2525from services .sentry import capture_exception
2626
2727
28- # =============================================================================
2928# DATA CLASSES
30- # =============================================================================
3129
3230@dataclass
3331class PlaygroundLimitResult :
@@ -134,9 +132,7 @@ def _truncate_id(session_id: str) -> str:
134132 return session_id
135133
136134
137- # =============================================================================
138135# MAIN CLASS
139- # =============================================================================
140136
141137class PlaygroundLimiter :
142138 """
@@ -161,9 +157,7 @@ class PlaygroundLimiter:
161157 has_repo = limiter.has_indexed_repo(session_token)
162158 """
163159
164- # -------------------------------------------------------------------------
165160 # Configuration
166- # -------------------------------------------------------------------------
167161
168162 # Rate limits
169163 SESSION_LIMIT_PER_DAY = 50 # Per device (generous for conversion)
@@ -198,9 +192,7 @@ def __init__(self, redis_client=None):
198192 """
199193 self .redis = redis_client
200194
201- # -------------------------------------------------------------------------
202195 # Session Data Methods (#127)
203- # -------------------------------------------------------------------------
204196
205197 def get_session_data (self , session_token : Optional [str ]) -> SessionData :
206198 """
@@ -449,9 +441,7 @@ def create_session(self, session_token: str) -> bool:
449441 capture_exception (e , operation = "create_session" )
450442 return False
451443
452- # -------------------------------------------------------------------------
453444 # Rate Limiting Methods (existing, updated for hash storage)
454- # -------------------------------------------------------------------------
455445
456446 def check_limit (
457447 self ,
@@ -657,9 +647,7 @@ def _check_ip_limit(self, client_ip: str, record: bool) -> Tuple[bool, int]:
657647 logger .error ("IP limit check failed" , error = str (e ))
658648 return True , self .IP_LIMIT_PER_DAY # Fail open
659649
660- # -------------------------------------------------------------------------
661650 # Helper Methods
662- # -------------------------------------------------------------------------
663651
664652 def _get_midnight_utc (self ) -> datetime :
665653 """Get next midnight UTC for reset time."""
@@ -788,9 +776,7 @@ def get_usage_stats(self) -> dict:
788776 return {"error" : str (e ), "redis_available" : False }
789777
790778
791- # =============================================================================
792779# SINGLETON
793- # =============================================================================
794780
795781_playground_limiter : Optional [PlaygroundLimiter ] = None
796782
0 commit comments