feat: switch all timezone naive datetimes to timezone aware

This commit is contained in:
Iain Learmonth 2024-12-06 16:08:48 +00:00
parent 41fc0a73a5
commit e22abb383c
30 changed files with 322 additions and 226 deletions

View file

@ -1,7 +1,7 @@
from datetime import datetime, timedelta
import logging
from abc import abstractmethod
from typing import Tuple, List, Callable, Optional, Any
from datetime import datetime, timedelta, timezone
from typing import Any, Callable, List, Optional, Tuple
from app.extensions import db
from app.models.activity import Activity
@ -25,14 +25,14 @@ class BlockBridgeAutomation(BaseAutomation):
super().__init__(*args, **kwargs)
def perform_deprecations(self, ids: List[str], bridge_select_func: Callable[[str], Optional[Bridge]]
) -> List[Tuple[str, str, str]]:
) -> List[Tuple[Optional[str], Any, Any]]:
rotated = []
for id_ in ids:
bridge = bridge_select_func(id_)
if bridge is None:
continue
logging.debug("Found %s blocked", bridge.hashed_fingerprint)
if bridge.added > datetime.utcnow() - timedelta(hours=3):
if bridge.added > datetime.now(tz=timezone.utc) - timedelta(hours=3):
logging.debug("Not rotating a bridge less than 3 hours old")
continue
if bridge.deprecate(reason=self.short_name):