45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""What waits for a person, and their decisions (append-only; the next run applies them)."""
|
|
|
|
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from pydantic import BaseModel
|
|
|
|
from core.pipeline import EntityName, Id
|
|
from persistance import nodes, review
|
|
from webapi.auth import Caller, caller
|
|
|
|
router = APIRouter(prefix="/review", tags=["review"])
|
|
Rows = list[dict[str, Any]]
|
|
|
|
|
|
@router.get("/held")
|
|
def held(entity: EntityName) -> Rows:
|
|
"""Rows a rule held, with the reasons and the values as they came."""
|
|
return review.held(entity)
|
|
|
|
|
|
@router.get("/conflicts")
|
|
def conflicts(entity: EntityName) -> Rows:
|
|
"""Rows of one person and date that disagree; reject the wrong ones."""
|
|
return review.conflicts(entity)
|
|
|
|
|
|
@router.get("/links")
|
|
def links(pipeline: Id, node: Id) -> Rows:
|
|
"""Records that may be the same person but were left apart."""
|
|
return review.links(pipeline, node)
|
|
|
|
|
|
class Rejection(BaseModel):
|
|
entity: EntityName
|
|
record: str
|
|
reason: str
|
|
|
|
|
|
@router.post("/rejections", status_code=201)
|
|
def reject(decision: Rejection, who: Caller = Depends(caller)) -> dict[str, str]:
|
|
"""This record's row must not reach silver; applied on the next run."""
|
|
nodes.reject(decision.entity, decision.record, decision.reason, who.id)
|
|
return {"record": decision.record}
|