Add Power BI reporting endpoints — flat tabular data via API key auth
Three read-only endpoints under /reporting/: - /hotels hotel dimension table (tier, stars, review score) - /rates full rates fact — all sources, room types, scrape history in one flat table - /occupancy Newbook occupancy per date × room category Rates UNION covers Booking.com scrapes, direct competitor engines (with configured room/rate labels), and own hotel Newbook headline rates. Authenticated via X-API-Key header; key stored in system_config.reporting_api_key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d5ce38859d
commit
e481ad5258
3 changed files with 264 additions and 3 deletions
|
|
@ -3,6 +3,8 @@ Rate Monitor — FastAPI Backend
|
|||
"""
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
logging.basicConfig(
|
||||
|
|
@ -15,7 +17,7 @@ from fastapi import FastAPI
|
|||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from database import DATABASE_URL
|
||||
from api import bookability, competitors, analysis, direct
|
||||
from api import bookability, competitors, analysis, direct, reporting
|
||||
from scheduler import start_scheduler, shutdown_scheduler
|
||||
|
||||
|
||||
|
|
@ -60,6 +62,7 @@ app = FastAPI(
|
|||
version="1.0.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
STARTED_AT = str(int(time.time() * 1000))
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
|
@ -73,8 +76,9 @@ app.include_router(bookability.router, prefix="/bookability", tags=["Book
|
|||
app.include_router(competitors.router, prefix="/competitors", tags=["Competitors"])
|
||||
app.include_router(analysis.router, prefix="/analysis", tags=["Rate Analysis"])
|
||||
app.include_router(direct.router, prefix="/direct", tags=["Direct Rates"])
|
||||
app.include_router(reporting.router, prefix="/reporting", tags=["Reporting"])
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
return {"status": "healthy", "service": "rate-monitor-api"}
|
||||
return {"status": "healthy", "service": "rate-monitor-api", "version": os.environ.get("BUILD_VERSION", STARTED_AT)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue