@@ -1834,7 +1834,7 @@ type SearchRepoOptions struct {
1834
1834
1835
1835
// SearchRepositoryByName takes keyword and part of repository name to search,
1836
1836
// it returns results in given range and number of total results.
1837
- func SearchRepositoryByName (opts * SearchRepoOptions ) (repos RepositoryList , _ int64 , _ error ) {
1837
+ func SearchRepositoryByName (opts * SearchRepoOptions ) (repos RepositoryList , count int64 , err error ) {
1838
1838
var (
1839
1839
sess * xorm.Session
1840
1840
cond = builder .NewCond ()
@@ -1870,7 +1870,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
1870
1870
var ownerIds []int64
1871
1871
1872
1872
ownerIds = append (ownerIds , opts .Searcher .ID )
1873
- err : = opts .Searcher .GetOrganizations (true )
1873
+ err = opts .Searcher .GetOrganizations (true )
1874
1874
1875
1875
if err != nil {
1876
1876
return nil , 0 , fmt .Errorf ("Organization: %v" , err )
@@ -1891,15 +1891,21 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
1891
1891
sess = x .
1892
1892
Join ("INNER" , "star" , "star.repo_id = repository.id" ).
1893
1893
Where (cond )
1894
+ count , err = x .
1895
+ Join ("INNER" , "star" , "star.repo_id = repository.id" ).
1896
+ Where (cond ).
1897
+ Count (new (Repository ))
1898
+ if err != nil {
1899
+ return nil , 0 , fmt .Errorf ("Count: %v" , err )
1900
+ }
1894
1901
} else {
1895
1902
sess = x .Where (cond )
1896
- }
1897
-
1898
- var countSess xorm.Session
1899
- countSess = * sess
1900
- count , err := countSess .Count (new (Repository ))
1901
- if err != nil {
1902
- return nil , 0 , fmt .Errorf ("Count: %v" , err )
1903
+ count , err = x .
1904
+ Where (cond ).
1905
+ Count (new (Repository ))
1906
+ if err != nil {
1907
+ return nil , 0 , fmt .Errorf ("Count: %v" , err )
1908
+ }
1903
1909
}
1904
1910
1905
1911
if err = sess .
@@ -1915,7 +1921,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
1915
1921
}
1916
1922
}
1917
1923
1918
- return repos , count , nil
1924
+ return
1919
1925
}
1920
1926
1921
1927
// DeleteRepositoryArchives deletes all repositories' archives.
0 commit comments