mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-22 04:59:45 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user