fix: Change timezone from UTC to UTC-3 for date filters to match database - backend v1.0.9
This commit is contained in:
@@ -1292,18 +1292,20 @@ def get_dashboard_data(
|
|||||||
|
|
||||||
# Aplicar filtros de fecha
|
# Aplicar filtros de fecha
|
||||||
if start_date:
|
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
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
query = query.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
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
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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)
|
query = query.filter(models.Inspection.started_at <= end)
|
||||||
|
|
||||||
# Filtro por mecánico
|
# Filtro por mecánico
|
||||||
@@ -1336,15 +1338,17 @@ def get_dashboard_data(
|
|||||||
|
|
||||||
if start_date:
|
if start_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
flagged_items = flagged_items.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
if end_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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)
|
flagged_items = flagged_items.filter(models.Inspection.started_at <= end)
|
||||||
if mechanic_id:
|
if mechanic_id:
|
||||||
flagged_items = flagged_items.filter(models.Inspection.mechanic_id == mechanic_id)
|
flagged_items = flagged_items.filter(models.Inspection.mechanic_id == mechanic_id)
|
||||||
@@ -1379,15 +1383,17 @@ def get_dashboard_data(
|
|||||||
|
|
||||||
if start_date:
|
if start_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
mechanic_stats = mechanic_stats.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
if end_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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.filter(models.Inspection.started_at <= end)
|
||||||
|
|
||||||
mechanic_stats = mechanic_stats.group_by(models.User.id, models.User.full_name)\
|
mechanic_stats = mechanic_stats.group_by(models.User.id, models.User.full_name)\
|
||||||
@@ -1422,15 +1428,17 @@ def get_dashboard_data(
|
|||||||
|
|
||||||
if start_date:
|
if start_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
checklist_stats_query = checklist_stats_query.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
if end_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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)
|
checklist_stats_query = checklist_stats_query.filter(models.Inspection.started_at <= end)
|
||||||
if mechanic_id:
|
if mechanic_id:
|
||||||
checklist_stats_query = checklist_stats_query.filter(models.Inspection.mechanic_id == 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:
|
if start_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
pass_fail_data = pass_fail_data.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
if end_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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)
|
pass_fail_data = pass_fail_data.filter(models.Inspection.started_at <= end)
|
||||||
if mechanic_id:
|
if mechanic_id:
|
||||||
pass_fail_data = pass_fail_data.filter(models.Inspection.mechanic_id == 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
|
# Aplicar filtros
|
||||||
if start_date:
|
if start_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
start = datetime.fromisoformat(start_date).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
if start.tzinfo is None:
|
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)
|
query = query.filter(models.Inspection.started_at >= start)
|
||||||
if end_date:
|
if end_date:
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
local_tz = timezone(timedelta(hours=-3))
|
||||||
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
end = datetime.fromisoformat(end_date).replace(hour=23, minute=59, second=59, microsecond=999999)
|
||||||
if end.tzinfo is None:
|
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)
|
query = query.filter(models.Inspection.started_at <= end)
|
||||||
if mechanic_id:
|
if mechanic_id:
|
||||||
query = query.filter(models.Inspection.mechanic_id == mechanic_id)
|
query = query.filter(models.Inspection.mechanic_id == mechanic_id)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: dymai/syntria-backend:latest
|
image: dymai/syntria-backend:1.0.9
|
||||||
container_name: syntria-backend-prod
|
container_name: syntria-backend-prod
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user