Stats collector for email monitoring
This commit is contained in:
@@ -32,6 +32,7 @@ from .customer_service import CustomerService
|
||||
from .db import Base, get_database_url
|
||||
from .db import Customer as DBCustomer
|
||||
from .db import Reservation as DBReservation
|
||||
from .email_monitoring import ReservationStatsCollector
|
||||
from .email_service import create_email_service
|
||||
from .logging_config import get_logger, setup_logging
|
||||
from .rate_limit import (
|
||||
@@ -245,8 +246,17 @@ async def lifespan(app: FastAPI):
|
||||
else:
|
||||
_LOGGER.info("All existing customers already have hashed data")
|
||||
|
||||
# Start daily report scheduler if enabled
|
||||
# Initialize and hook up stats collector for daily reports
|
||||
if report_scheduler:
|
||||
stats_collector = ReservationStatsCollector(
|
||||
async_sessionmaker=AsyncSessionLocal,
|
||||
config=config,
|
||||
)
|
||||
# Hook up the stats collector to the report scheduler
|
||||
report_scheduler.set_stats_collector(stats_collector.collect_stats)
|
||||
_LOGGER.info("Stats collector initialized and hooked up to report scheduler")
|
||||
|
||||
# Start daily report scheduler
|
||||
report_scheduler.start()
|
||||
_LOGGER.info("Daily report scheduler started")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user