@@ -657,6 +657,7 @@ type AccessibleReposEnvironment interface {
657
657
Repos (page , pageSize int ) ([]* Repository , error )
658
658
MirrorRepos () ([]* Repository , error )
659
659
AddKeyword (keyword string )
660
+ SetSort (SearchOrderBy )
660
661
}
661
662
662
663
type accessibleReposEnv struct {
@@ -665,6 +666,7 @@ type accessibleReposEnv struct {
665
666
teamIDs []int64
666
667
e Engine
667
668
keyword string
669
+ orderBy SearchOrderBy
668
670
}
669
671
670
672
// AccessibleReposEnv an AccessibleReposEnvironment for the repositories in `org`
@@ -683,6 +685,7 @@ func (org *User) accessibleReposEnv(e Engine, userID int64) (AccessibleReposEnvi
683
685
userID : userID ,
684
686
teamIDs : teamIDs ,
685
687
e : e ,
688
+ orderBy : SearchOrderByRecentUpdated ,
686
689
}, nil
687
690
}
688
691
@@ -722,8 +725,8 @@ func (env *accessibleReposEnv) RepoIDs(page, pageSize int) ([]int64, error) {
722
725
Table ("repository" ).
723
726
Join ("INNER" , "team_repo" , "`team_repo`.repo_id=`repository`.id" ).
724
727
Where (env .cond ()).
725
- GroupBy ("`repository`.id,`repository`.updated_unix" ).
726
- OrderBy ("updated_unix DESC" ).
728
+ GroupBy ("`repository`.id,`repository`." + strings . Fields ( string ( env . orderBy ))[ 0 ] ).
729
+ OrderBy (string ( env . orderBy ) ).
727
730
Limit (pageSize , (page - 1 )* pageSize ).
728
731
Cols ("`repository`.id" ).
729
732
Find (& repoIDs )
@@ -742,6 +745,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
742
745
743
746
return repos , env .e .
744
747
In ("`repository`.id" , repoIDs ).
748
+ OrderBy (string (env .orderBy )).
745
749
Find (& repos )
746
750
}
747
751
@@ -752,7 +756,7 @@ func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
752
756
Join ("INNER" , "team_repo" , "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?" , true ).
753
757
Where (env .cond ()).
754
758
GroupBy ("`repository`.id, `repository`.updated_unix" ).
755
- OrderBy ("updated_unix DESC" ).
759
+ OrderBy (string ( env . orderBy ) ).
756
760
Cols ("`repository`.id" ).
757
761
Find (& repoIDs )
758
762
}
@@ -776,3 +780,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
776
780
func (env * accessibleReposEnv ) AddKeyword (keyword string ) {
777
781
env .keyword = keyword
778
782
}
783
+
784
+ func (env * accessibleReposEnv ) SetSort (orderBy SearchOrderBy ) {
785
+ env .orderBy = orderBy
786
+ }
0 commit comments