Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 500 error on /explore/repos page #946

Merged
merged 1 commit into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,10 +1198,8 @@ func Repositories(opts *SearchRepoOptions) (_ RepositoryList, err error) {
return nil, fmt.Errorf("Repo: %v", err)
}

if opts.Searcher != nil || opts.Starred {
if err = repos.loadAttributes(x); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}
if err = repos.loadAttributes(x); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}

return repos, nil
Expand Down Expand Up @@ -1743,10 +1741,8 @@ func GetRecentUpdatedRepositories(opts *SearchRepoOptions) (repos RepositoryList
return nil, fmt.Errorf("Repo: %v", err)
}

if opts.Searcher != nil || opts.Starred {
if err = repos.loadAttributes(x); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}
if err = repos.loadAttributes(x); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}

return repos, nil
Expand Down Expand Up @@ -1781,14 +1777,15 @@ func GetPrivateRepositoryCount(u *User) (int64, error) {

// SearchRepoOptions holds the search options
type SearchRepoOptions struct {
Keyword string
OwnerID int64
Searcher *User //ID of the person who's seeking
OrderBy string
Private bool // Include private repositories in results
Starred bool
Page int
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
Keyword string
OwnerID int64
Searcher *User //ID of the person who's seeking
OrderBy string
Private bool // Include private repositories in results
Starred bool
Page int
IsProfile bool
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
}

// SearchRepositoryByName takes keyword and part of repository name to search,
Expand Down Expand Up @@ -1856,7 +1853,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
return nil, 0, fmt.Errorf("Repo: %v", err)
}

if opts.Searcher != nil || opts.Starred {
if !opts.IsProfile {
if err = repos.loadAttributes(x); err != nil {
return nil, 0, fmt.Errorf("LoadAttributes: %v", err)
}
Expand Down
13 changes: 7 additions & 6 deletions routers/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ func Profile(ctx *context.Context) {
ctx.Data["Total"] = total
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
OwnerID: ctxUser.ID,
OrderBy: orderBy,
Private: showPrivate,
Page: page,
PageSize: setting.UI.User.RepoPagingNum,
Keyword: keyword,
OwnerID: ctxUser.ID,
OrderBy: orderBy,
Private: showPrivate,
Page: page,
IsProfile: true,
PageSize: setting.UI.User.RepoPagingNum,
})
if err != nil {
ctx.Handle(500, "SearchRepositoryByName", err)
Expand Down