Add initial implementation of CalMiner with project structure, environment setup, and core features
- Create .env.example for environment variables - Update README with project structure and development setup instructions - Implement FastAPI application with API routes for scenarios and parameters - Add database models for scenarios, parameters, and simulation results - Introduce validation middleware for JSON requests - Create services for running simulations and generating reports - Add testing strategy and directory structure in documentation
This commit is contained in:
23
routes/reporting.py
Normal file
23
routes/reporting.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from fastapi import APIRouter, HTTPException, Depends
|
||||
from typing import Dict, Any
|
||||
|
||||
from services.reporting import generate_report
|
||||
from sqlalchemy.orm import Session
|
||||
from config.database import SessionLocal
|
||||
|
||||
router = APIRouter(prefix="/api/reporting", tags=["Reporting"])
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@router.post("/summary", response_model=Dict[str, float])
|
||||
async def summary_report(results: Any):
|
||||
# Expect a list of simulation result dicts
|
||||
if not isinstance(results, list):
|
||||
raise HTTPException(status_code=400, detail="Invalid input format")
|
||||
report = generate_report(results)
|
||||
return report
|
||||
Reference in New Issue
Block a user