feat(etl): stable pipeline, exception registry in SQLite, multi-pass aggregation and db_cli
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, Dict, List
|
||||
from services.exceptions_repo import get_all_exceptions_from_db, add_exception_to_db, remove_exception_from_db
|
||||
|
||||
router = APIRouter(prefix="/api/v1/exceptions", tags=["Exceptions"])
|
||||
|
||||
|
||||
class ExceptionItem(BaseModel):
|
||||
category: str
|
||||
value: str
|
||||
comment: Optional[str] = ""
|
||||
|
||||
|
||||
@router.get("/")
|
||||
def api_get_exceptions():
|
||||
return get_all_exceptions_from_db()
|
||||
|
||||
|
||||
@router.post("/")
|
||||
def api_add_exception(item: ExceptionItem):
|
||||
if not add_exception_to_db(item.category, item.value, item.comment):
|
||||
raise HTTPException(status_code=400, detail="Ошибка добавления исключения")
|
||||
return {"status": "success", "data": item}
|
||||
|
||||
|
||||
@router.delete("/")
|
||||
def api_delete_exception(category: str, value: str):
|
||||
if not remove_exception_from_db(category, value):
|
||||
raise HTTPException(status_code=404, detail="Исключение не найдено")
|
||||
return {"status": "success"}
|
||||
Reference in New Issue
Block a user