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) {
622
622
}
623
623
}
624
624
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
+
626
639
repos , count , err := repo_model .SearchRepository (ctx , opts )
627
640
if err != nil {
628
641
ctx .JSON (http .StatusInternalServerError , api.SearchError {
@@ -634,11 +647,6 @@ func SearchRepo(ctx *context.Context) {
634
647
635
648
ctx .SetTotalCountHeader (count )
636
649
637
- // To improve performance when only the count is requested
638
- if ctx .FormBool ("count_only" ) {
639
- return
640
- }
641
-
642
650
latestCommitStatuses , err := commitstatus_service .FindReposLastestCommitStatuses (ctx , repos )
643
651
if err != nil {
644
652
log .Error ("FindReposLastestCommitStatuses: %v" , err )
You can’t perform that action at this time.
0 commit comments