Why not return topics in Repository? #13035

Closed
opened 2025-11-02 10:28:19 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @Gitttttttt on GitHub (May 27, 2024).

Feature Description

I want to display the corresponding topic information in the repository list on the homepage, but the repository infomation does not contain topics information.

I must loop to obtain the corresponding topics after obtaining the repository list. This is very time-consuming. Can you return the corresponding topic list while querying the repository? Because the topics and the repository are actually in one table

Screenshots

No response

Originally created by @Gitttttttt on GitHub (May 27, 2024). ### Feature Description I want to display the corresponding topic information in the repository list on the homepage, but the repository infomation does not contain topics information. I must loop to obtain the corresponding topics after obtaining the repository list. This is very time-consuming. Can you return the corresponding topic list while querying the repository? Because the topics and the repository are actually in one table ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 10:28:19 -06:00
Author
Owner

@lunny commented on GitHub (May 27, 2024):

They are not on the same table. Did you mean API? If that, which API did you mean?

@lunny commented on GitHub (May 27, 2024): They are not on the same table. Did you mean API? If that, which API did you mean?
Author
Owner

@Gitttttttt commented on GitHub (May 28, 2024):

@lunny But I see that they are indeed in the same table:

image

So I think it is reasonable to return repositories with the topics while searching repositories or getting a repository, such as GET /repos/{owner}/{repo} and GET /repos/search

And the type Repository dose not have a topics attribute

type Repository struct {
ID int64 json:"id"
Owner *User json:"owner"
Name string json:"name"
FullName string json:"full_name"
Description string json:"description"
Empty bool json:"empty"
Private bool json:"private"
Fork bool json:"fork"
Template bool json:"template"
Parent *Repository json:"parent"
Mirror bool json:"mirror"
Size int json:"size"
HTMLURL string json:"html_url"
SSHURL string json:"ssh_url"
CloneURL string json:"clone_url"
OriginalURL string json:"original_url"
Website string json:"website"
Stars int json:"stars_count"
Forks int json:"forks_count"
Watchers int json:"watchers_count"
OpenIssues int json:"open_issues_count"
OpenPulls int json:"open_pr_counter"
Releases int json:"release_counter"
DefaultBranch string json:"default_branch"
Archived bool json:"archived"
Created time.Time json:"created_at"
Updated time.Time json:"updated_at"
Permissions *Permission json:"permissions,omitempty"
HasIssues bool json:"has_issues"
InternalTracker *InternalTracker json:"internal_tracker,omitempty"
ExternalTracker *ExternalTracker json:"external_tracker,omitempty"
HasWiki bool json:"has_wiki"
ExternalWiki *ExternalWiki json:"external_wiki,omitempty"
HasPullRequests bool json:"has_pull_requests"
HasProjects bool json:"has_projects"
HasReleases bool json:"has_releases,omitempty"
HasPackages bool json:"has_packages,omitempty"
HasActions bool json:"has_actions,omitempty"
IgnoreWhitespaceConflicts bool json:"ignore_whitespace_conflicts"
AllowMerge bool json:"allow_merge_commits"
AllowRebase bool json:"allow_rebase"
AllowRebaseMerge bool json:"allow_rebase_explicit"
AllowSquash bool json:"allow_squash_merge"
AvatarURL string json:"avatar_url"
Internal bool json:"internal"
MirrorInterval string json:"mirror_interval"
MirrorUpdated time.Time json:"mirror_updated,omitempty"
DefaultMergeStyle MergeStyle json:"default_merge_style"
}

@Gitttttttt commented on GitHub (May 28, 2024): @lunny But I see that they are indeed in the same table: ![image](https://github.com/go-gitea/gitea/assets/38375081/3c5be2fa-8cc8-42d9-89da-1cad06abda4e) So I think it is reasonable to return repositories with the topics while searching repositories or getting a repository, such as `GET /repos/{owner}/{repo}` and `GET /repos/search` And the type Repository dose not have a `topics` attribute type Repository struct { ID [int64](https://pkg.go.dev/builtin#int64) `json:"id"` Owner *[User](https://pkg.go.dev/code.gitea.io/sdk/gitea#User) `json:"owner"` Name [string](https://pkg.go.dev/builtin#string) `json:"name"` FullName [string](https://pkg.go.dev/builtin#string) `json:"full_name"` Description [string](https://pkg.go.dev/builtin#string) `json:"description"` Empty [bool](https://pkg.go.dev/builtin#bool) `json:"empty"` Private [bool](https://pkg.go.dev/builtin#bool) `json:"private"` Fork [bool](https://pkg.go.dev/builtin#bool) `json:"fork"` Template [bool](https://pkg.go.dev/builtin#bool) `json:"template"` Parent *[Repository](https://pkg.go.dev/code.gitea.io/sdk/gitea#Repository) `json:"parent"` Mirror [bool](https://pkg.go.dev/builtin#bool) `json:"mirror"` Size [int](https://pkg.go.dev/builtin#int) `json:"size"` HTMLURL [string](https://pkg.go.dev/builtin#string) `json:"html_url"` SSHURL [string](https://pkg.go.dev/builtin#string) `json:"ssh_url"` CloneURL [string](https://pkg.go.dev/builtin#string) `json:"clone_url"` OriginalURL [string](https://pkg.go.dev/builtin#string) `json:"original_url"` Website [string](https://pkg.go.dev/builtin#string) `json:"website"` Stars [int](https://pkg.go.dev/builtin#int) `json:"stars_count"` Forks [int](https://pkg.go.dev/builtin#int) `json:"forks_count"` Watchers [int](https://pkg.go.dev/builtin#int) `json:"watchers_count"` OpenIssues [int](https://pkg.go.dev/builtin#int) `json:"open_issues_count"` OpenPulls [int](https://pkg.go.dev/builtin#int) `json:"open_pr_counter"` Releases [int](https://pkg.go.dev/builtin#int) `json:"release_counter"` DefaultBranch [string](https://pkg.go.dev/builtin#string) `json:"default_branch"` Archived [bool](https://pkg.go.dev/builtin#bool) `json:"archived"` Created [time](https://pkg.go.dev/time).[Time](https://pkg.go.dev/time#Time) `json:"created_at"` Updated [time](https://pkg.go.dev/time).[Time](https://pkg.go.dev/time#Time) `json:"updated_at"` Permissions *[Permission](https://pkg.go.dev/code.gitea.io/sdk/gitea#Permission) `json:"permissions,omitempty"` HasIssues [bool](https://pkg.go.dev/builtin#bool) `json:"has_issues"` InternalTracker *[InternalTracker](https://pkg.go.dev/code.gitea.io/sdk/gitea#InternalTracker) `json:"internal_tracker,omitempty"` ExternalTracker *[ExternalTracker](https://pkg.go.dev/code.gitea.io/sdk/gitea#ExternalTracker) `json:"external_tracker,omitempty"` HasWiki [bool](https://pkg.go.dev/builtin#bool) `json:"has_wiki"` [ExternalWiki](https://pkg.go.dev/code.gitea.io/sdk/gitea#ExternalWiki) *ExternalWiki `json:"external_wiki,omitempty"` HasPullRequests [bool](https://pkg.go.dev/builtin#bool) `json:"has_pull_requests"` HasProjects [bool](https://pkg.go.dev/builtin#bool) `json:"has_projects"` HasReleases [bool](https://pkg.go.dev/builtin#bool) `json:"has_releases,omitempty"` HasPackages [bool](https://pkg.go.dev/builtin#bool) `json:"has_packages,omitempty"` HasActions [bool](https://pkg.go.dev/builtin#bool) `json:"has_actions,omitempty"` IgnoreWhitespaceConflicts [bool](https://pkg.go.dev/builtin#bool) `json:"ignore_whitespace_conflicts"` AllowMerge [bool](https://pkg.go.dev/builtin#bool) `json:"allow_merge_commits"` AllowRebase [bool](https://pkg.go.dev/builtin#bool) `json:"allow_rebase"` AllowRebaseMerge [bool](https://pkg.go.dev/builtin#bool) `json:"allow_rebase_explicit"` AllowSquash [bool](https://pkg.go.dev/builtin#bool) `json:"allow_squash_merge"` AvatarURL [string](https://pkg.go.dev/builtin#string) `json:"avatar_url"` Internal [bool](https://pkg.go.dev/builtin#bool) `json:"internal"` MirrorInterval [string](https://pkg.go.dev/builtin#string) `json:"mirror_interval"` MirrorUpdated [time](https://pkg.go.dev/time).[Time](https://pkg.go.dev/time#Time) `json:"mirror_updated,omitempty"` DefaultMergeStyle [MergeStyle](https://pkg.go.dev/code.gitea.io/sdk/gitea#MergeStyle) `json:"default_merge_style"` }
Author
Owner

@lunny commented on GitHub (May 28, 2024):

Ah, right. I forgot there is a cache column.

@lunny commented on GitHub (May 28, 2024): Ah, right. I forgot there is a cache column.
Author
Owner

@Gitttttttt commented on GitHub (May 28, 2024):

Ah, right. I forgot there is a cache column.

@lunny So can you carry the topics field in the return results of the repository list? If you do this, Things will become very simple. Thanks very much

@Gitttttttt commented on GitHub (May 28, 2024): > Ah, right. I forgot there is a cache column. @lunny So can you carry the `topics` field in the return results of the repository list? If you do this, Things will become very simple. Thanks very much
Author
Owner

@lunny commented on GitHub (May 30, 2024):

Resovled by #31127

@lunny commented on GitHub (May 30, 2024): Resovled by #31127
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13035