explore: fix total repository number and page number do not match ()

Because in the final repository list we use Distinct to remove
duplicates, but didn't do so when count total number of repositories.
pull/4633/head
Unknwon 2017-07-18 22:07:40 -04:00
parent dc10594d7b
commit ee9950ec2f
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
1 changed files with 2 additions and 3 deletions
models

View File

@ -1659,9 +1659,8 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, _ int
sess.And("repo.owner_id = ?", opts.OwnerID) sess.And("repo.owner_id = ?", opts.OwnerID)
} }
var countSess xorm.Session // We need all fields (repo.*) in final list but only ID (repo.id) is good enough for counting.
countSess = *sess count, err = sess.Clone().Distinct("repo.id").Count(new(Repository))
count, err := countSess.Count(new(Repository))
if err != nil { if err != nil {
return nil, 0, fmt.Errorf("Count: %v", err) return nil, 0, fmt.Errorf("Count: %v", err)
} }