fix: replace pytz with zoneinfo, fix predictive insights list/dict bug
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m15s

This commit is contained in:
ismail 2026-05-12 01:32:41 +03:00
parent 76b514d521
commit 7dae32d206
2 changed files with 6 additions and 6 deletions

View File

@ -2626,14 +2626,13 @@ class OnCallAdminSchedule(UUIDModel, TimeStampedModel):
Returns: Returns:
bool: True if within working hours, False otherwise bool: True if within working hours, False otherwise
""" """
import pytz
from datetime import time as datetime_time from datetime import time as datetime_time
from zoneinfo import ZoneInfo
if check_datetime is None: if check_datetime is None:
check_datetime = timezone.now() check_datetime = timezone.now()
# Convert to schedule timezone tz = ZoneInfo(self.timezone)
tz = pytz.timezone(self.timezone)
if timezone.is_aware(check_datetime): if timezone.is_aware(check_datetime):
local_time = check_datetime.astimezone(tz) local_time = check_datetime.astimezone(tz)
else: else:

View File

@ -301,11 +301,12 @@ def generate_predictive_insights():
predictive_service = PredictiveAnalyticsService() predictive_service = PredictiveAnalyticsService()
result = predictive_service.generate_predictive_insights() result = predictive_service.generate_predictive_insights()
logger.info(f"Predictive insights generated: {result.get('insights_created', 0)} insights created") insights_created = len(result) if isinstance(result, list) else result.get("insights_created", 0)
logger.info(f"Predictive insights generated: {insights_created} insights created")
return { return {
"status": "success", "status": "success",
"insights_created": result.get("insights_created", 0), "insights_created": insights_created,
"insights_updated": result.get("insights_updated", 0), "insights_updated": result.get("insights_updated", 0) if isinstance(result, dict) else 0,
} }
except Exception as e: except Exception as e: