Improve te panel de control logic
This commit is contained in:
@@ -37,6 +37,8 @@ DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6") # Ind
|
||||
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7") # Central bakery
|
||||
|
||||
# Base reference date for date calculations
|
||||
# MUST match shared/utils/demo_dates.py for proper demo session cloning
|
||||
# This fixed date allows demo sessions to adjust all dates relative to session creation time
|
||||
BASE_REFERENCE_DATE = datetime(2025, 1, 15, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
@@ -140,7 +142,19 @@ async def seed_batches_for_tenant(
|
||||
actual_end = actual_start + timedelta(minutes=actual_duration)
|
||||
completed_at = actual_end
|
||||
elif batch_data["status"] == "IN_PROGRESS":
|
||||
actual_start = planned_start
|
||||
# For IN_PROGRESS batches, set actual_start to a recent time to ensure valid progress calculation
|
||||
# If planned_start is in the past, use it; otherwise, set to 30 minutes ago
|
||||
now = datetime.now(timezone.utc)
|
||||
if planned_start < now:
|
||||
# If planned start was in the past, use a time that ensures batch is ~30% complete
|
||||
elapsed_time_minutes = min(
|
||||
int(batch_data["planned_duration_minutes"] * 0.3),
|
||||
int((now - planned_start).total_seconds() / 60)
|
||||
)
|
||||
actual_start = now - timedelta(minutes=elapsed_time_minutes)
|
||||
else:
|
||||
# If planned_start is in the future, start batch 30 minutes ago
|
||||
actual_start = now - timedelta(minutes=30)
|
||||
actual_duration = None
|
||||
actual_end = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user