feat(api): state filter + populated num_issues on project columns
Adds two improvements to the user/org/repo project-board REST API: * state filter on column-issues endpoints (issue #4) GET /api/v1/{users,orgs}/{name}/-/projects/{id}/columns/{col}/issues GET /api/v1/repos/{owner}/{repo}/projects/{id}/columns/{col}/issues Now accept ?state=open|closed|all (default open), matching the convention on the project-list endpoint and on /repos/.../issues. Applied at the IssuesOptions layer so all three scopes inherit the filter. * populated num_issues / num_open_issues / num_closed_issues on column-list (issue #5) ColumnList.LoadIssueCounts runs two grouped queries against project_issue joined with issue (one open, one closed). All three List*Columns handlers call it before converting, so num_issues stops being null and consumers can render a kanban summary in a single round trip instead of N+1. Tests: * unit: empty-input fast path on ColumnList.LoadIssueCounts. * integration: extended testAPIListProjectColumnIssues / -User / -Org to close an issue, then verify default=open hides it, state=closed and state=all return it, and the column-list response carries the correct open/closed/total split. Closes #4, closes #5
This commit is contained in:
@@ -147,15 +147,17 @@ func ToProjectColumn(ctx context.Context, column *project_model.Column, doer *us
|
||||
|
||||
func toProjectColumn(ctx context.Context, column *project_model.Column, doer *user_model.User, creators map[int64]*user_model.User) *api.ProjectColumn {
|
||||
apiColumn := &api.ProjectColumn{
|
||||
ID: column.ID,
|
||||
Title: column.Title,
|
||||
Default: column.Default,
|
||||
Sorting: int(column.Sorting),
|
||||
Color: column.Color,
|
||||
ProjectID: column.ProjectID,
|
||||
NumIssues: column.NumIssues,
|
||||
CreatedAt: column.CreatedUnix.AsTime(),
|
||||
UpdatedAt: column.UpdatedUnix.AsTime(),
|
||||
ID: column.ID,
|
||||
Title: column.Title,
|
||||
Default: column.Default,
|
||||
Sorting: int(column.Sorting),
|
||||
Color: column.Color,
|
||||
ProjectID: column.ProjectID,
|
||||
NumIssues: column.NumIssues,
|
||||
NumOpenIssues: column.NumOpenIssues,
|
||||
NumClosedIssues: column.NumClosedIssues,
|
||||
CreatedAt: column.CreatedUnix.AsTime(),
|
||||
UpdatedAt: column.UpdatedUnix.AsTime(),
|
||||
}
|
||||
if creator, ok := creators[column.CreatorID]; ok {
|
||||
apiColumn.Creator = ToUser(ctx, creator, doer)
|
||||
|
||||
Reference in New Issue
Block a user