Adds visitor dashboard and related features
This commit is contained in:
+25
-1
@@ -1,4 +1,6 @@
|
||||
from contextlib import asynccontextmanager
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -8,7 +10,7 @@ from app.config import settings
|
||||
from app.database import async_session, engine
|
||||
from app.models import Base, Show, StationConfig, HistoryEntry, TeamMember, CommunityHighlight, Underwriter
|
||||
from app.user_models import User
|
||||
from app.api import events, auth, station_config, history, team, community, shows, storage, underwriters
|
||||
from app.api import events, auth, station_config, history, team, community, shows, storage, underwriters, stats
|
||||
|
||||
|
||||
def _migrate_add_missing_columns(sync_conn):
|
||||
@@ -117,6 +119,27 @@ async def lifespan(app: FastAPI):
|
||||
await session.commit()
|
||||
print(f" → Bootstrap admin created: {settings.ADMIN_USERNAME}")
|
||||
|
||||
# Check GeoLite2 database
|
||||
geo_db = settings.GEOLITE2_DB_PATH
|
||||
if os.path.exists(geo_db):
|
||||
print(f" ✓ GeoLite2 database loaded from {geo_db}")
|
||||
else:
|
||||
print(f" WARNING: GeoLite2 database not found at {geo_db} — geo lookups will be disabled")
|
||||
|
||||
# Auto-parse any unprocessed logs on startup (background task)
|
||||
async def _startup_parse():
|
||||
try:
|
||||
from app.log_parser import process_unparsed_logs
|
||||
result = await process_unparsed_logs()
|
||||
if result.get("files_processed"):
|
||||
print(f" ✓ Parsed {result['files_processed']} log files ({result['rows_inserted']} geo rows)")
|
||||
else:
|
||||
print(" No unprocessed log files to parse")
|
||||
except Exception as e:
|
||||
print(f" ERROR during startup log parse: {e}")
|
||||
|
||||
asyncio.create_task(_startup_parse())
|
||||
|
||||
yield
|
||||
|
||||
|
||||
@@ -145,6 +168,7 @@ app.include_router(community.router, prefix="/api/community", tags=["community"]
|
||||
app.include_router(shows.router, prefix="/api/shows", tags=["shows"])
|
||||
app.include_router(storage.router, prefix="/api/storage", tags=["storage"])
|
||||
app.include_router(underwriters.router, prefix="/api/underwriters", tags=["underwriters"])
|
||||
app.include_router(stats.router, prefix="/api/stats", tags=["stats"])
|
||||
|
||||
# Dev-only admin router (disabled in production)
|
||||
if settings.ENV != "production":
|
||||
|
||||
Reference in New Issue
Block a user