Backend: Assessment list
GitHub Issue: #215
Last modified with commit 374306c on
by Aljaž.
Backend task for the assessment list (GET /assessments) – check the API spec and DB structure, permissions and visibility, implement filters, sorting and pagination, and verify against the spec.
Docs: Assessment list
Spec: GET /assessments (getAssessments), Assessment, AssessmentStatus in api-docs/openapi.yaml
DB: Assessments, AssessmentCandidates (search), AssessmentBoardMembers (visibility) in api/database/create_schema.sql
1. Double check API spec and DB structure
- Every list column in the docs is in
Assessment(name, brand, partner, date, status, candidates count, created by…). - Filters match the docs: search by name and candidate name, date range, brand (MARKA),
status (PRIKAŽI). Check the parameter formats (
dateRangeasstart/end). - Sorting: active → upcoming → past, then date ascending. Check the docs agree.
- Pagination: the docs say the page size isn’t specified (Figma shows pagination). Set a
default
perPagein the spec. - Do the actions menu rules (edit only for active/upcoming, delete only for upcoming) need
any flags in the response, or does the frontend work them out from
status? - Roles and permissions: list =
assessments.access; seeing all assessments =assessments.access-all(Trainer). Assessment evaluators see only assessments they are an active board member of. Check this against the docs permission table, and decide what a removed board member sees (expected: the assessment disappears). - DB: status is not stored, so it has to be filtered as a date condition. Check the
indexes support the query (
IX_Assessments_Date,IX_AssessmentBoardMembers_UserId). Assessments are soft-deleted (see Backend: Delete assessment), so the list must leave out rows whereDeletedAtis set.
2. Implementation
- Roles and permissions: use
assessments.accessandassessments.access-all, plus the shared “is the caller an active board member” check (UserId= caller andDeletedAt IS NULL). Add the check if it doesn’t exist yet. - DB: turn
statusinto a date condition using today’s date in Europe/Zagreb (the same helper as the calculatedstatus). - Search: case-insensitive, matching
Assessments.Nameor any candidate’sFullName. No duplicate rows when several candidates match. - Brand filter:
brandCodecontained inBrandCodes. - Sorting and pagination (
Pagination, as for other lists).
3. Verify implementation against spec
- Query parameter names, the response envelope and the item shape match
getAssessments. - Trainer sees all; evaluator sees only assessments they are a member of; a removed member no longer sees the assessment.
- The status filter is correct around midnight Europe/Zagreb.
Done when
The list works with every filter, sort and pagination option from the docs, for both roles.