diff --git a/backend/app/api/coding.py b/backend/app/api/coding.py index bc2740a..0d58d03 100644 --- a/backend/app/api/coding.py +++ b/backend/app/api/coding.py @@ -19,6 +19,7 @@ router = APIRouter() @router.get("/queue", response_model=CaseListResponse) def coding_queue( fallgruppe: str | None = Query(None), + jahr: int | None = Query(None), page: int = Query(1, ge=1), per_page: int = Query(50, ge=1, le=200), db: Session = Depends(get_db), @@ -26,9 +27,9 @@ def coding_queue( ): """Return cases that need coding (gutachten=True, gutachten_typ=NULL). - Admin only. Supports optional fallgruppe filter and pagination. + Admin only. Supports optional fallgruppe and jahr filters with pagination. """ - cases, total = get_coding_queue(db, fallgruppe, page, per_page) + cases, total = get_coding_queue(db, fallgruppe, jahr, page, per_page) return CaseListResponse( items=[CaseResponse.model_validate(c) for c in cases], total=total, diff --git a/backend/app/services/coding_service.py b/backend/app/services/coding_service.py index 5b802b2..0228843 100644 --- a/backend/app/services/coding_service.py +++ b/backend/app/services/coding_service.py @@ -14,6 +14,7 @@ settings = get_settings() def get_coding_queue( db: Session, fallgruppe: str | None = None, + jahr: int | None = None, page: int = 1, per_page: int = 50, ) -> tuple[list[Case], int]: @@ -32,6 +33,8 @@ def get_coding_queue( ) if fallgruppe: query = query.filter(Case.fallgruppe == fallgruppe) + if jahr: + query = query.filter(Case.jahr == jahr) total = query.count() cases = ( diff --git a/frontend/src/pages/CodingPage.tsx b/frontend/src/pages/CodingPage.tsx index 03d08f3..e488e91 100644 --- a/frontend/src/pages/CodingPage.tsx +++ b/frontend/src/pages/CodingPage.tsx @@ -48,6 +48,9 @@ function getInitialFormState(c: Case): CodingFormState { } export function CodingPage() { + const currentYear = new Date().getFullYear() + const years = Array.from({ length: 5 }, (_, i) => currentYear - i) + const [jahr, setJahr] = useState('__all__') const [fallgruppe, setFallgruppe] = useState('__all__') const [page, setPage] = useState(1) const [data, setData] = useState(null) @@ -63,6 +66,7 @@ export function CodingPage() { setLoading(true) const params: Record = { page, per_page: 50 } if (fallgruppe !== '__all__') params.fallgruppe = fallgruppe + if (jahr !== '__all__') params.jahr = Number(jahr) api.get('/coding/queue', { params, signal: controller.signal }) .then((res) => { @@ -84,7 +88,7 @@ export function CodingPage() { }) return () => controller.abort() - }, [page, fallgruppe]) + }, [page, fallgruppe, jahr]) const updateFormField = (caseId: number, field: keyof CodingFormState, value: unknown) => { setFormStates((prev) => ({ @@ -136,9 +140,9 @@ export function CodingPage() { ? data.items.filter((c) => savedIds.has(c.id) || c.gutachten_typ !== null).length : 0 const grandTotal = data?.total ?? 0 - const activeFilterLabel = fallgruppe !== '__all__' - ? FALLGRUPPEN_LABELS[fallgruppe] || fallgruppe - : null + const activeFilters: string[] = [] + if (fallgruppe !== '__all__') activeFilters.push(FALLGRUPPEN_LABELS[fallgruppe] || fallgruppe) + if (jahr !== '__all__') activeFilters.push(jahr) return (
@@ -148,8 +152,8 @@ export function CodingPage() { {!loading && data && (

{grandTotal} {grandTotal === 1 ? 'Fall' : 'Fälle'} offen - {activeFilterLabel && ( - <> — gefiltert nach {activeFilterLabel} + {activeFilters.length > 0 && ( + <> — gefiltert nach {activeFilters.join(', ')} )}

)} @@ -158,6 +162,17 @@ export function CodingPage() { {codedCount} / {data?.items.length ?? 0} auf dieser Seite codiert +