File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -622,26 +622,31 @@ 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
+ if count , err := repo_model .CountRepository (ctx , opts ); err != nil {
628
+ log .Error ("CountRepository: %v" , err )
629
+ ctx .JSON (http .StatusInternalServerError , nil ) // frontend JS doesn't handle error response (same as below)
630
+ } else {
631
+ ctx .SetTotalCountHeader (count )
632
+ ctx .JSONOK ()
633
+ }
634
+ return
635
+ }
636
+
626
637
repos , count , err := repo_model .SearchRepository (ctx , opts )
627
638
if err != nil {
628
- ctx .JSON (http .StatusInternalServerError , api.SearchError {
629
- OK : false ,
630
- Error : err .Error (),
631
- })
639
+ log .Error ("SearchRepository: %v" , err )
640
+ ctx .JSON (http .StatusInternalServerError , nil )
632
641
return
633
642
}
634
643
635
644
ctx .SetTotalCountHeader (count )
636
645
637
- // To improve performance when only the count is requested
638
- if ctx .FormBool ("count_only" ) {
639
- return
640
- }
641
-
642
646
latestCommitStatuses , err := commitstatus_service .FindReposLastestCommitStatuses (ctx , repos )
643
647
if err != nil {
644
648
log .Error ("FindReposLastestCommitStatuses: %v" , err )
649
+ ctx .JSON (http .StatusInternalServerError , nil )
645
650
return
646
651
}
647
652
Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ const sfc = {
235
235
if (! this .reposTotalCount ) {
236
236
const totalCountSearchURL = ` ${ this .subUrl } /repo/search?count_only=1&uid=${ this .uid } &team_id=${ this .teamId } &q=&page=1&mode=` ;
237
237
response = await GET (totalCountSearchURL);
238
- this .reposTotalCount = response .headers .get (' X-Total-Count' );
238
+ this .reposTotalCount = response .headers .get (' X-Total-Count' ) ?? ' ? ' ;
239
239
}
240
240
241
241
response = await GET (searchedURL);
You can’t perform that action at this time.
0 commit comments