forked from forgejo/forgejo
Fix: Sort repos on org home page with non-admin login (#6741)
This commit is contained in:
parent
821184c203
commit
ff03b2f606
3 changed files with 55 additions and 3 deletions
|
@ -657,6 +657,7 @@ type AccessibleReposEnvironment interface {
|
|||
Repos(page, pageSize int) ([]*Repository, error)
|
||||
MirrorRepos() ([]*Repository, error)
|
||||
AddKeyword(keyword string)
|
||||
SetSort(SearchOrderBy)
|
||||
}
|
||||
|
||||
type accessibleReposEnv struct {
|
||||
|
@ -665,6 +666,7 @@ type accessibleReposEnv struct {
|
|||
teamIDs []int64
|
||||
e Engine
|
||||
keyword string
|
||||
orderBy SearchOrderBy
|
||||
}
|
||||
|
||||
// AccessibleReposEnv an AccessibleReposEnvironment for the repositories in `org`
|
||||
|
@ -683,6 +685,7 @@ func (org *User) accessibleReposEnv(e Engine, userID int64) (AccessibleReposEnvi
|
|||
userID: userID,
|
||||
teamIDs: teamIDs,
|
||||
e: e,
|
||||
orderBy: SearchOrderByRecentUpdated,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -722,8 +725,8 @@ func (env *accessibleReposEnv) RepoIDs(page, pageSize int) ([]int64, error) {
|
|||
Table("repository").
|
||||
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id").
|
||||
Where(env.cond()).
|
||||
GroupBy("`repository`.id,`repository`.updated_unix").
|
||||
OrderBy("updated_unix DESC").
|
||||
GroupBy("`repository`.id,`repository`."+strings.Fields(string(env.orderBy))[0]).
|
||||
OrderBy(string(env.orderBy)).
|
||||
Limit(pageSize, (page-1)*pageSize).
|
||||
Cols("`repository`.id").
|
||||
Find(&repoIDs)
|
||||
|
@ -742,6 +745,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
|
|||
|
||||
return repos, env.e.
|
||||
In("`repository`.id", repoIDs).
|
||||
OrderBy(string(env.orderBy)).
|
||||
Find(&repos)
|
||||
}
|
||||
|
||||
|
@ -752,7 +756,7 @@ func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
|
|||
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true).
|
||||
Where(env.cond()).
|
||||
GroupBy("`repository`.id, `repository`.updated_unix").
|
||||
OrderBy("updated_unix DESC").
|
||||
OrderBy(string(env.orderBy)).
|
||||
Cols("`repository`.id").
|
||||
Find(&repoIDs)
|
||||
}
|
||||
|
@ -776,3 +780,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
|
|||
func (env *accessibleReposEnv) AddKeyword(keyword string) {
|
||||
env.keyword = keyword
|
||||
}
|
||||
|
||||
func (env *accessibleReposEnv) SetSort(orderBy SearchOrderBy) {
|
||||
env.orderBy = orderBy
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue