- 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-05-03 14:32:38 +05:30
committed by beardev-in
co-authored by Claude
parent 45832f4d68
commit 438f367ab3
5 changed files with 35 additions and 93 deletions
+5 -9
View File
@@ -35,15 +35,11 @@ func ToProject(ctx context.Context, p *project_model.Project) *api.Project {
project.ClosedDate = &t
}
// Generate project URL
if p.Type == project_model.TypeRepository && p.RepoID > 0 {
if err := p.LoadRepo(ctx); err == nil && p.Repo != nil {
project.URL = project_model.ProjectLinkForRepo(p.Repo, p.ID)
}
} else if p.OwnerID > 0 {
if err := p.LoadOwner(ctx); err == nil && p.Owner != nil {
project.URL = project_model.ProjectLinkForOrg(p.Owner, p.ID)
}
// Repo/Owner are expected to be preloaded by the caller to avoid N+1 lookups.
if p.Type == project_model.TypeRepository && p.Repo != nil {
project.URL = project_model.ProjectLinkForRepo(p.Repo, p.ID)
} else if p.Owner != nil {
project.URL = project_model.ProjectLinkForOrg(p.Owner, p.ID)
}
return project