New alert system and panel de control page

This commit is contained in:
Urtzi Alfaro
2025-11-27 15:52:40 +01:00
parent 1a2f4602f3
commit e902419b6e
178 changed files with 20982 additions and 6944 deletions

View File

@@ -26,16 +26,17 @@ import structlog
from app.models.forecasts import Forecast, PredictionBatch
# Add shared path for demo utilities
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
from shared.utils.demo_dates import BASE_REFERENCE_DATE
# Configure logging
logger = structlog.get_logger()
# Base demo tenant IDs
DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6") # Individual bakery
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7") # Central bakery
# Base reference date for date calculations
BASE_REFERENCE_DATE = datetime(2025, 1, 15, 12, 0, 0, tzinfo=timezone.utc)
# Day of week mapping
DAYS_OF_WEEK = {
0: "lunes",
@@ -442,8 +443,25 @@ async def seed_all(db: AsyncSession):
}
def validate_base_reference_date():
"""Ensure BASE_REFERENCE_DATE hasn't changed since last seed"""
expected_date = datetime(2025, 1, 8, 6, 0, 0, tzinfo=timezone.utc)
if BASE_REFERENCE_DATE != expected_date:
logger.warning(
"BASE_REFERENCE_DATE has changed! This may cause date inconsistencies.",
current=BASE_REFERENCE_DATE.isoformat(),
expected=expected_date.isoformat()
)
# Don't fail - just warn. Allow intentional changes.
logger.info("BASE_REFERENCE_DATE validation", date=BASE_REFERENCE_DATE.isoformat())
async def main():
"""Main execution function"""
validate_base_reference_date() # Add this line
# Get database URL from environment
database_url = os.getenv("FORECASTING_DATABASE_URL")
if not database_url: