feat(api): state filter + populated num_issues on project columns #6
Reference in New Issue
Block a user
Delete Branch "feat/project-column-state-filter-and-counts"
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?
Two small REST-API improvements to the user/org/repo project-board endpoints we added in #2.
Closes #4
Closes #5
#4 — state filter on column-issues
GET /api/v1/{users,orgs}/{name}/-/projects/{id}/columns/{col}/issuesand the repo equivalent now accept?state=open|closed|all(defaultopen), matching the convention used on the project-list endpoint and on/repos/.../issues.Applied at the
issues_model.IssuesOptionslayer (IsClosed: common.ParseIssueFilterStateIsClosed(...)) so all three scopes inherit the filter from a single line each.Before: every issue ever attached to the column was returned, mixing open and closed cards. Callers had to filter client-side after pulling the full page.
After: the default response only returns open issues; closed cards are reachable via
state=closed/state=all.#5 — populated
num_issues(plus open/closed split)num_issueson the column-list response was alwaysnull. AddedColumnList.LoadIssueCountsinmodels/project/column_list.go, which runs two grouped queries againstproject_issue ⋈ issue(one for open, one for closed) and populatesNumOpenIssues/NumClosedIssues/NumIssueson every column. All threeList*Columnshandlers call it before converting.Also added
num_open_issuesandnum_closed_issuesto theProjectColumnAPI struct to mirror the shape ofProject.omitemptywas dropped on these three fields so a column with 0 issues serializes as0rather than disappearing (which would be just as unhelpful as the oldnull).Files changed
models/project/column.go— addNumOpenIssues/NumClosedIssues(xorm-) toColumnmodels/project/column_list.go—ColumnList.LoadIssueCounts(+countColumnIssuesByStatehelper)modules/structs/project.go— exposenum_open_issues/num_closed_issuesonProjectColumn, dropomitemptyservices/convert/project.go— copy the new fields into the API payloadrouters/api/v1/{repo,user,org}/project.go— wirestate=into the column-issues handlers and callLoadIssueCountsfrom the column-list handlers (+ swagger param entries)models/project/column_list_test.go— empty-input fast-path unit test (full count behaviour is covered by integration tests since the unit fixture set has noissuetable)tests/integration/api_{repo,user,org}_project_test.go— close an issue mid-test, assert default-open hides it,state=closed/state=allsurface it, and the column-list response carries the correct open/closed/total splitTest plan
go test ./models/project/... ./services/convert/... ./modules/structs/...GITEA_TEST_DATABASE=sqlite TAGS=sqlite go test -tags=sqlite -run 'TestAPIProjects|TestAPIUserProjects|TestAPIOrgProjects' ./tests/integration/...— all three project test suites greengo vet ./...andgo build ./...cleanDeployment
Do not merge until the live Gitea instance can absorb a redeploy — this PR was opened against the same Gitea it would patch.