demo seed change 4
This commit is contained in:
@@ -251,26 +251,44 @@ async def clone_demo_data(
|
||||
|
||||
# Set default location if not provided in seed data
|
||||
location = forecast_data.get('location') or "Main Bakery"
|
||||
|
||||
|
||||
# Get or calculate forecast date
|
||||
forecast_date = forecast_data.get('forecast_date')
|
||||
if not forecast_date:
|
||||
forecast_date = session_time
|
||||
|
||||
# Calculate day_of_week from forecast_date if not provided
|
||||
# day_of_week should be 0-6 (Monday=0, Sunday=6)
|
||||
day_of_week = forecast_data.get('day_of_week')
|
||||
if day_of_week is None and forecast_date:
|
||||
day_of_week = forecast_date.weekday()
|
||||
|
||||
# Calculate is_weekend from day_of_week if not provided
|
||||
is_weekend = forecast_data.get('is_weekend')
|
||||
if is_weekend is None and day_of_week is not None:
|
||||
is_weekend = day_of_week >= 5 # Saturday=5, Sunday=6
|
||||
else:
|
||||
is_weekend = False
|
||||
|
||||
new_forecast = Forecast(
|
||||
id=transformed_id,
|
||||
tenant_id=virtual_uuid,
|
||||
inventory_product_id=inventory_product_id,
|
||||
product_name=forecast_data.get('product_name'),
|
||||
location=location,
|
||||
forecast_date=forecast_data.get('forecast_date'),
|
||||
forecast_date=forecast_date,
|
||||
created_at=forecast_data.get('created_at', session_time),
|
||||
predicted_demand=predicted_demand,
|
||||
confidence_lower=forecast_data.get('confidence_lower', max(0.0, float(predicted_demand or 0.0) * 0.8)),
|
||||
confidence_upper=forecast_data.get('confidence_upper', max(0.0, float(predicted_demand or 0.0) * 1.2)),
|
||||
confidence_level=forecast_data.get('confidence_level', 0.8),
|
||||
model_id=forecast_data.get('model_id'),
|
||||
model_version=forecast_data.get('model_version'),
|
||||
model_id=forecast_data.get('model_id') or 'default-fallback-model',
|
||||
model_version=forecast_data.get('model_version') or '1.0',
|
||||
algorithm=forecast_data.get('algorithm', 'prophet'),
|
||||
business_type=forecast_data.get('business_type', 'individual'),
|
||||
day_of_week=forecast_data.get('day_of_week'),
|
||||
day_of_week=day_of_week,
|
||||
is_holiday=forecast_data.get('is_holiday', False),
|
||||
is_weekend=forecast_data.get('is_weekend', False),
|
||||
is_weekend=is_weekend,
|
||||
weather_temperature=forecast_data.get('weather_temperature'),
|
||||
weather_precipitation=forecast_data.get('weather_precipitation'),
|
||||
weather_description=forecast_data.get('weather_description'),
|
||||
|
||||
@@ -385,7 +385,7 @@ class EnhancedForecastingService:
|
||||
"confidence_lower": adjusted_prediction.get('lower_bound', max(0.0, float(adjusted_prediction.get('prediction') or 0.0) * 0.8)),
|
||||
"confidence_upper": adjusted_prediction.get('upper_bound', max(0.0, float(adjusted_prediction.get('prediction') or 0.0) * 1.2)),
|
||||
"confidence_level": request.confidence_level,
|
||||
"model_id": model_data['model_id'],
|
||||
"model_id": model_data.get('model_id') or 'default-fallback-model',
|
||||
"model_version": str(model_data.get('version', '1.0')),
|
||||
"algorithm": model_data.get('algorithm', 'prophet'),
|
||||
"business_type": features.get('business_type', 'individual'),
|
||||
|
||||
Reference in New Issue
Block a user