Skip to content

Commit 69f54db

Browse files
committed
Fix the duplicated repositories load on dashboard
1 parent 16e3600 commit 69f54db

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

routers/web/repo/repo.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)