fix: fixing db time again
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-18 14:47:47 -04:00
parent dc96df70f8
commit beb471d081
2 changed files with 12 additions and 13 deletions
+1 -1
View File
@@ -1 +1 @@
2.4.6 2.4.7
+11 -12
View File
@@ -546,26 +546,23 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
import os import os
start_time = datetime.now() start_time = datetime.now()
# Try to get local timezone - handle Docker container case # Handle timezone display - check if TZ is set in container
try: try:
# Check if TZ environment variable is set
tz_name = os.environ.get('TZ') tz_name = os.environ.get('TZ')
if tz_name: if tz_name:
import zoneinfo # TZ is set, so datetime.now() already returns local time
local_tz = zoneinfo.ZoneInfo(tz_name) local_start = start_time
local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
tz_display = f" ({tz_name})" tz_display = f" ({tz_name})"
else: else:
# Fallback: assume EDT/EST based on PostgreSQL logs showing EDT # No TZ set, assume container is UTC and convert to Eastern
# This is a reasonable assumption for your deployment
import zoneinfo import zoneinfo
local_tz = zoneinfo.ZoneInfo("America/New_York") local_tz = zoneinfo.ZoneInfo("America/New_York")
local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz) local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
tz_display = " (EDT/EST)" tz_display = " (EDT/EST)"
except: except:
# Ultimate fallback - just show UTC with note # Ultimate fallback - just show time as-is with note
local_start = start_time local_start = start_time
tz_display = " (UTC - container time)" tz_display = " (container time)"
print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {local_start.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}") print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {local_start.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}")
@@ -658,16 +655,18 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
try: try:
tz_name = os.environ.get('TZ') tz_name = os.environ.get('TZ')
if tz_name: if tz_name:
local_tz = zoneinfo.ZoneInfo(tz_name) # TZ is set, so datetime.now() already returns local time
local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz) local_end = end_time
tz_display = f" ({tz_name})" tz_display = f" ({tz_name})"
else: else:
# No TZ set, assume container is UTC and convert to Eastern
import zoneinfo
local_tz = zoneinfo.ZoneInfo("America/New_York") local_tz = zoneinfo.ZoneInfo("America/New_York")
local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz) local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
tz_display = " (EDT/EST)" tz_display = " (EDT/EST)"
except: except:
local_end = end_time local_end = end_time
tz_display = " (UTC - container time)" tz_display = " (container time)"
print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {local_end.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}") print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {local_end.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}")
print(f"⏱️ MANUAL SCAN DURATION: {duration_str} (total time: {duration.total_seconds():.1f} seconds)") print(f"⏱️ MANUAL SCAN DURATION: {duration_str} (total time: {duration.total_seconds():.1f} seconds)")