- 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:
silverwind
2026-04-27 12:19:57 +02:00
committed by beardev-in
parent 45832f4d68
commit 438f367ab3
5 changed files with 35 additions and 93 deletions

View File

@@ -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))
}