From 7dae32d20628e546397346a4ea98bf8ad8bb5c6c Mon Sep 17 00:00:00 2001 From: ismail Date: Tue, 12 May 2026 01:32:41 +0300 Subject: [PATCH] fix: replace pytz with zoneinfo, fix predictive insights list/dict bug --- apps/complaints/models.py | 5 ++--- apps/executive_summary/tasks.py | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/complaints/models.py b/apps/complaints/models.py index 4e04d3d..90d209c 100644 --- a/apps/complaints/models.py +++ b/apps/complaints/models.py @@ -2626,14 +2626,13 @@ class OnCallAdminSchedule(UUIDModel, TimeStampedModel): Returns: bool: True if within working hours, False otherwise """ - import pytz from datetime import time as datetime_time + from zoneinfo import ZoneInfo if check_datetime is None: check_datetime = timezone.now() - # Convert to schedule timezone - tz = pytz.timezone(self.timezone) + tz = ZoneInfo(self.timezone) if timezone.is_aware(check_datetime): local_time = check_datetime.astimezone(tz) else: diff --git a/apps/executive_summary/tasks.py b/apps/executive_summary/tasks.py index 659b3c2..8fdfe65 100644 --- a/apps/executive_summary/tasks.py +++ b/apps/executive_summary/tasks.py @@ -301,11 +301,12 @@ def generate_predictive_insights(): predictive_service = PredictiveAnalyticsService() 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 { "status": "success", - "insights_created": result.get("insights_created", 0), - "insights_updated": result.get("insights_updated", 0), + "insights_created": insights_created, + "insights_updated": result.get("insights_updated", 0) if isinstance(result, dict) else 0, } except Exception as e: