From 5d2a96553e8c7421f1b841c0a32ef2952e0c039d Mon Sep 17 00:00:00 2001 From: ronalds Date: Thu, 20 Nov 2025 15:20:09 -0300 Subject: [PATCH] fix: Change timezone from UTC to UTC-3 for date filters to match database - backend v1.0.9 --- backend/app/main.py | 40 ++++++++++++++++++++++++++-------------- docker-compose.hub.yml | 2 +- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index b2453ac..f39cd87 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1292,18 +1292,20 @@ def get_dashboard_data( # Aplicar filtros de fecha if start_date: - # Parsear fecha y establecer al inicio del día en UTC + # Parsear fecha y establecer al inicio del día en UTC-3 from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) query = query.filter(models.Inspection.started_at >= start) if end_date: - # Parsear fecha y establecer al final del día en UTC + # Parsear fecha y establecer al final del día en UTC-3 from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) query = query.filter(models.Inspection.started_at <= end) # Filtro por mecánico @@ -1336,15 +1338,17 @@ def get_dashboard_data( if start_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) flagged_items = flagged_items.filter(models.Inspection.started_at >= start) if end_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) flagged_items = flagged_items.filter(models.Inspection.started_at <= end) if mechanic_id: flagged_items = flagged_items.filter(models.Inspection.mechanic_id == mechanic_id) @@ -1379,15 +1383,17 @@ def get_dashboard_data( if start_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) mechanic_stats = mechanic_stats.filter(models.Inspection.started_at >= start) if end_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) mechanic_stats = mechanic_stats.filter(models.Inspection.started_at <= end) mechanic_stats = mechanic_stats.group_by(models.User.id, models.User.full_name)\ @@ -1422,15 +1428,17 @@ def get_dashboard_data( if start_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) checklist_stats_query = checklist_stats_query.filter(models.Inspection.started_at >= start) if end_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) checklist_stats_query = checklist_stats_query.filter(models.Inspection.started_at <= end) if mechanic_id: checklist_stats_query = checklist_stats_query.filter(models.Inspection.mechanic_id == mechanic_id) @@ -1483,15 +1491,17 @@ def get_dashboard_data( if start_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) pass_fail_data = pass_fail_data.filter(models.Inspection.started_at >= start) if end_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) pass_fail_data = pass_fail_data.filter(models.Inspection.started_at <= end) if mechanic_id: pass_fail_data = pass_fail_data.filter(models.Inspection.mechanic_id == mechanic_id) @@ -1549,15 +1559,17 @@ def get_inspections_report( # Aplicar filtros if start_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0) if start.tzinfo is None: - start = start.replace(tzinfo=timezone.utc) + start = start.replace(tzinfo=local_tz) query = query.filter(models.Inspection.started_at >= start) if end_date: from datetime import timezone + local_tz = timezone(timedelta(hours=-3)) end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999) if end.tzinfo is None: - end = end.replace(tzinfo=timezone.utc) + end = end.replace(tzinfo=local_tz) query = query.filter(models.Inspection.started_at <= end) if mechanic_id: query = query.filter(models.Inspection.mechanic_id == mechanic_id) diff --git a/docker-compose.hub.yml b/docker-compose.hub.yml index 2504547..999dcff 100644 --- a/docker-compose.hub.yml +++ b/docker-compose.hub.yml @@ -20,7 +20,7 @@ services: retries: 5 backend: - image: dymai/syntria-backend:latest + image: dymai/syntria-backend:1.0.9 container_name: syntria-backend-prod restart: always depends_on: