Landing imporvement
This commit is contained in:
@@ -189,30 +189,46 @@ async def generate_orchestration_for_tenant(
|
||||
runs_created = 0
|
||||
steps_created = 0
|
||||
|
||||
# Special case: Create at least 1 recent completed run for "today" (for dashboard visibility)
|
||||
# This ensures the dashboard "Listo Para Planificar Tu Día" shows data
|
||||
today_run_created = False
|
||||
|
||||
for i in range(total_runs):
|
||||
# Determine temporal distribution
|
||||
rand_temporal = random.random()
|
||||
cumulative = 0
|
||||
temporal_category = None
|
||||
|
||||
for category, details in orch_config["temporal_distribution"].items():
|
||||
cumulative += details["percentage"]
|
||||
if rand_temporal <= cumulative:
|
||||
temporal_category = details
|
||||
break
|
||||
|
||||
if not temporal_category:
|
||||
# For the first run, create it for today with completed status
|
||||
if i == 0 and not today_run_created:
|
||||
temporal_category = orch_config["temporal_distribution"]["completed"]
|
||||
# Use current time instead of BASE_REFERENCE_DATE
|
||||
now = datetime.now(timezone.utc)
|
||||
# Set offset to create run that started yesterday and completed today
|
||||
offset_days = 0 # Today
|
||||
run_date = now.date()
|
||||
today_run_created = True
|
||||
# Force status to completed for dashboard visibility
|
||||
status = "completed"
|
||||
else:
|
||||
# Determine temporal distribution
|
||||
rand_temporal = random.random()
|
||||
cumulative = 0
|
||||
temporal_category = None
|
||||
|
||||
# Calculate run date
|
||||
offset_days = random.randint(
|
||||
temporal_category["offset_days_min"],
|
||||
temporal_category["offset_days_max"]
|
||||
)
|
||||
run_date = calculate_date_from_offset(offset_days)
|
||||
for category, details in orch_config["temporal_distribution"].items():
|
||||
cumulative += details["percentage"]
|
||||
if rand_temporal <= cumulative:
|
||||
temporal_category = details
|
||||
break
|
||||
|
||||
# Select status
|
||||
status = random.choice(temporal_category["statuses"])
|
||||
if not temporal_category:
|
||||
temporal_category = orch_config["temporal_distribution"]["completed"]
|
||||
|
||||
# Calculate run date
|
||||
offset_days = random.randint(
|
||||
temporal_category["offset_days_min"],
|
||||
temporal_category["offset_days_max"]
|
||||
)
|
||||
run_date = calculate_date_from_offset(offset_days)
|
||||
|
||||
# Select status
|
||||
status = random.choice(temporal_category["statuses"])
|
||||
|
||||
# Select run type
|
||||
run_type_choice = weighted_choice(orch_config["run_types"])
|
||||
@@ -232,19 +248,26 @@ async def generate_orchestration_for_tenant(
|
||||
run_number = generate_run_number(tenant_id, i + 1, run_type)
|
||||
|
||||
# Calculate timing based on status
|
||||
started_at = calculate_datetime_from_offset(offset_days - 1)
|
||||
completed_at = None
|
||||
duration_seconds = None
|
||||
# For today's run (i==0), use current datetime instead of BASE_REFERENCE_DATE
|
||||
if i == 0 and today_run_created:
|
||||
now = datetime.now(timezone.utc)
|
||||
started_at = now - timedelta(hours=2) # Started 2 hours ago
|
||||
completed_at = now - timedelta(minutes=30) # Completed 30 minutes ago
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
else:
|
||||
started_at = calculate_datetime_from_offset(offset_days - 1)
|
||||
completed_at = None
|
||||
duration_seconds = None
|
||||
|
||||
if status in ["completed", "partial_success"]:
|
||||
completed_at = calculate_datetime_from_offset(offset_days)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
elif status == "failed":
|
||||
completed_at = calculate_datetime_from_offset(offset_days - 0.5)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
elif status == "cancelled":
|
||||
completed_at = calculate_datetime_from_offset(offset_days - 0.2)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
if status in ["completed", "partial_success"]:
|
||||
completed_at = calculate_datetime_from_offset(offset_days)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
elif status == "failed":
|
||||
completed_at = calculate_datetime_from_offset(offset_days - 0.5)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
elif status == "cancelled":
|
||||
completed_at = calculate_datetime_from_offset(offset_days - 0.2)
|
||||
duration_seconds = int((completed_at - started_at).total_seconds())
|
||||
|
||||
# Generate step timing
|
||||
forecasting_started_at = started_at
|
||||
|
||||
Reference in New Issue
Block a user