Simplify
- Drop lazy LoadRepo/LoadOwner in convert.ToProject; rely on caller preloading. ListProjects sets Repo from ctx.Repo.Repository on each project; CreateProject does the same on the new project. Avoids N+1 queries for repo-scoped list endpoints. - Strip redundant API struct field comments that just restate the field name; keep the ones that document enum values. - Pre-allocate GetColumnsByIDs result slice with len(columnsIDs). - Fix CountProjectColumns doc comment (was "CountColumns"). Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
@@ -118,6 +118,9 @@ func ListProjects(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range projects {
|
||||
p.Repo = ctx.Repo.Repository
|
||||
}
|
||||
apiProjects := convert.ToProjectList(ctx, projects)
|
||||
|
||||
ctx.SetLinkHeader(count, listOptions.PageSize)
|
||||
@@ -217,6 +220,7 @@ func CreateProject(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
p.Repo = ctx.Repo.Repository
|
||||
ctx.JSON(http.StatusCreated, convert.ToProject(ctx, p))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user