New alert service
This commit is contained in:
@@ -172,11 +172,24 @@ def generate_reasoning_metadata(
|
||||
This creates structured reasoning data that the alert processor can use to provide
|
||||
context when showing AI reasoning to users.
|
||||
"""
|
||||
# Calculate aggregate metrics for dashboard display
|
||||
# Dashboard expects these fields at the top level of the 'reasoning' object
|
||||
critical_items_count = random.randint(1, 3) if purchase_orders_created > 0 else 0
|
||||
financial_impact_eur = random.randint(200, 1500) if critical_items_count > 0 else 0
|
||||
min_depletion_hours = random.uniform(6.0, 48.0) if critical_items_count > 0 else 0
|
||||
|
||||
reasoning_metadata = {
|
||||
'reasoning': {
|
||||
'type': 'daily_orchestration_summary',
|
||||
'timestamp': datetime.now(timezone.utc).isoformat(),
|
||||
# TOP-LEVEL FIELDS - Dashboard reads these directly (dashboard_service.py:411-413)
|
||||
'critical_items_count': critical_items_count,
|
||||
'financial_impact_eur': round(financial_impact_eur, 2),
|
||||
'min_depletion_hours': round(min_depletion_hours, 1),
|
||||
'time_until_consequence_hours': round(min_depletion_hours, 1),
|
||||
'affected_orders': random.randint(0, 5) if critical_items_count > 0 else 0,
|
||||
'summary': 'Daily orchestration run completed successfully',
|
||||
# Keep existing details structure for backward compatibility
|
||||
'details': {
|
||||
'forecasting': {
|
||||
'forecasts_created': forecasts_generated,
|
||||
@@ -419,11 +432,20 @@ async def generate_orchestration_for_tenant(
|
||||
notification_error = error_scenario["message"]
|
||||
|
||||
# Generate results summary
|
||||
forecasts_generated = random.randint(5, 15)
|
||||
production_batches_created = random.randint(3, 8)
|
||||
procurement_plans_created = random.randint(2, 6)
|
||||
purchase_orders_created = random.randint(1, 4)
|
||||
notifications_sent = random.randint(10, 25)
|
||||
# For professional tenant, use realistic fixed counts that match PO seed data
|
||||
if tenant_id == DEMO_TENANT_PROFESSIONAL:
|
||||
forecasts_generated = 12 # Realistic daily forecast count
|
||||
production_batches_created = 6 # Realistic batch count
|
||||
procurement_plans_created = 3 # 3 procurement plans
|
||||
purchase_orders_created = 18 # Total POs including 9 delivery POs (PO #11-18)
|
||||
notifications_sent = 24 # Realistic notification count
|
||||
else:
|
||||
# Enterprise tenant can keep random values
|
||||
forecasts_generated = random.randint(5, 15)
|
||||
production_batches_created = random.randint(3, 8)
|
||||
procurement_plans_created = random.randint(2, 6)
|
||||
purchase_orders_created = random.randint(1, 4)
|
||||
notifications_sent = random.randint(10, 25)
|
||||
|
||||
# Generate performance metrics for completed runs
|
||||
fulfillment_rate = None
|
||||
|
||||
Reference in New Issue
Block a user