Fix repo grouping to order by group_header in database query
Some checks failed
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m58s
Build and Release / Create Release (push) Successful in 0s
Build and Release / Lint (push) Successful in 5m3s
Build and Release / Unit Tests (push) Successful in 5m23s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 2m50s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Failing after 8h4m22s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 10m46s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Successful in 10m45s
Build and Release / Build Binary (linux/arm64) (push) Failing after 2m42s
Some checks failed
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m58s
Build and Release / Create Release (push) Successful in 0s
Build and Release / Lint (push) Successful in 5m3s
Build and Release / Unit Tests (push) Successful in 5m23s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 2m50s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Failing after 8h4m22s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 10m46s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Successful in 10m45s
Build and Release / Build Binary (linux/arm64) (push) Failing after 2m42s
Previously, repos were paginated first then grouped, causing groups to be split across pages. Now when grouping is enabled: 1. Order by group_header first in DB query (keeps groups together) 2. Support ?limit=N parameter (max 100) to show more repos per page Example: /org/repositories?limit=50 shows 50 repos per page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,17 @@ func home(ctx *context.Context, viewRepositories bool) {
|
||||
page = 1
|
||||
}
|
||||
|
||||
// Allow custom page size via limit parameter (max 100, default from settings)
|
||||
pageSize := ctx.FormInt("limit")
|
||||
if pageSize <= 0 || pageSize > 100 {
|
||||
pageSize = setting.UI.User.RepoPagingNum
|
||||
}
|
||||
ctx.Data["PageSize"] = pageSize
|
||||
|
||||
// Check if grouping is enabled (default: true)
|
||||
showGrouping := ctx.FormString("show_groups") != "0"
|
||||
ctx.Data["ShowGrouping"] = showGrouping
|
||||
|
||||
archived := ctx.FormOptionalBool("archived")
|
||||
ctx.Data["IsArchived"] = archived
|
||||
|
||||
@@ -221,14 +232,20 @@ func home(ctx *context.Context, viewRepositories bool) {
|
||||
ctx.Data["PageIsViewOverview"] = isViewOverview
|
||||
ctx.Data["ShowOrgProfileReadmeSelector"] = isViewOverview && prepareResult.ProfilePublicReadmeBlob != nil && prepareResult.ProfilePrivateReadmeBlob != nil
|
||||
|
||||
// When grouping is enabled, order by group_header first to keep groups together
|
||||
finalOrderBy := orderBy
|
||||
if showGrouping {
|
||||
finalOrderBy = db.SearchOrderBy("group_header ASC, " + string(orderBy))
|
||||
}
|
||||
|
||||
repos, count, err := repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
PageSize: pageSize,
|
||||
Page: page,
|
||||
},
|
||||
Keyword: keyword,
|
||||
OwnerID: org.ID,
|
||||
OrderBy: orderBy,
|
||||
OrderBy: finalOrderBy,
|
||||
Private: ctx.IsSigned,
|
||||
Actor: ctx.Doer,
|
||||
Language: language,
|
||||
@@ -248,9 +265,6 @@ func home(ctx *context.Context, viewRepositories bool) {
|
||||
ctx.Data["Total"] = count
|
||||
|
||||
// Group repos by GroupHeader for grouped view
|
||||
showGrouping := ctx.FormString("show_groups") != "0" // default to true
|
||||
ctx.Data["ShowGrouping"] = showGrouping
|
||||
|
||||
if showGrouping {
|
||||
groupedRepos := make(map[string][]*repo_model.Repository)
|
||||
var headers []string
|
||||
@@ -280,7 +294,7 @@ func home(ctx *context.Context, viewRepositories bool) {
|
||||
ctx.Data["RepoHeaders"] = headers
|
||||
}
|
||||
|
||||
pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
||||
pager := context.NewPagination(int(count), pageSize, page, 5)
|
||||
pager.AddParamFromRequest(ctx.Req)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user