Add project field to list_notes API response #118
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-api!118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "117-add-project-field-to-list-notes-api-resp"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds a lightweight
projectfield (slug + name) to theNoteSummaryschema returned byGET /notes, so operators can audit project distribution across all notes without callingget_note262 times individually.Changes
src/pal_e_docs/schemas.py-- AddedProjectSummaryschema (slug, name only) and addedproject: ProjectSummary | NonetoNoteSummarysrc/pal_e_docs/routes/notes.py-- Addedjoinedload(Note.project)to thelist_notesquery to eagerly load project datatests/test_list_notes_project.py-- 6 new unit tests covering assigned notes, unassigned notes, project filter, lightweight schema shape, mixed results, and existing filter compatibilityTest Plan
test_list_notes_project.py)GET /notesreturnsproject: {slug, name}for assigned notes andproject: nullfor unassignedReview Checklist
get_noteunchanged, new field is additive)Related
plan-2026-02-26-tf-modularize-postgres(traceability)PR #118 Review
BLOCKERS
None.
NITS
ProjectSummaryplacement -- The new schema class is inserted betweenNoteOutandNoteSummary. This is a reasonable location, but consider grouping it near the otherProject*schemas (ProjectCreate,ProjectUpdate,ProjectOut) at the top of the file for discoverability. Non-blocking since the current placement keeps it adjacent to its only consumer (NoteSummary).joinedload+ explicitjoininteraction -- When the?project=alphaquery param is used, the query does bothjoinedload(Note.project)(for eager-loading the relationship) and.join(Project, Note.project_id == Project.id)(for filtering). SQLAlchemy handles this correctly via aliased joins forjoinedload, so there is no correctness issue. Just noting it for future readers -- this is the expected SQLAlchemy pattern.SOP COMPLIANCE
117-add-project-field-to-list-notes-api-respreferences issue #117)plan-2026-02-26-tf-modularize-postgres)tests/test_list_notes_project.py)projectfield defaults toNone)CODE REVIEW
Schema (
schemas.py):ProjectSummaryis a clean, minimal schema with onlyslugandname. It usesfrom_attributes = Truewhich correctly allows Pydantic to read from the SQLAlchemyProjectmodel. Theproject: ProjectSummary | None = Nonedefault onNoteSummaryensures backward compatibility.Query (
routes/notes.py): Addingjoinedload(Note.project)to the existing query options is the right approach. It prevents N+1 queries when serializing the project field across all notes. TheNote.projectrelationship exists inmodels.py(line 108) and maps toproject_idFK.Tests (
test_list_notes_project.py): All 6 tests cover meaningful scenarios:nullslug+namekeys)PR body reports 540 tests passing with 0 failures.
VERDICT: APPROVED