File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -622,7 +622,20 @@ func SearchRepo(ctx *context.Context) {
622622 }
623623 }
624624
625- var err error
625+ // To improve performance when only the count is requested
626+ if ctx .FormBool ("count_only" ) {
627+ count , err := repo_model .CountRepository (ctx , opts )
628+ if err != nil {
629+ ctx .JSON (http .StatusInternalServerError , api.SearchError {
630+ OK : false ,
631+ Error : err .Error (),
632+ })
633+ return
634+ }
635+ ctx .SetTotalCountHeader (count )
636+ return
637+ }
638+
626639 repos , count , err := repo_model .SearchRepository (ctx , opts )
627640 if err != nil {
628641 ctx .JSON (http .StatusInternalServerError , api.SearchError {
@@ -634,11 +647,6 @@ func SearchRepo(ctx *context.Context) {
634647
635648 ctx .SetTotalCountHeader (count )
636649
637- // To improve performance when only the count is requested
638- if ctx .FormBool ("count_only" ) {
639- return
640- }
641-
642650 latestCommitStatuses , err := commitstatus_service .FindReposLastestCommitStatuses (ctx , repos )
643651 if err != nil {
644652 log .Error ("FindReposLastestCommitStatuses: %v" , err )
You can’t perform that action at this time.
0 commit comments