diff options
author | Andrey Nering <andrey.nering@gmail.com> | 2017-02-04 10:32:55 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-04 10:32:55 -0200 |
commit | d4035d1cb143a758463f2e3ee9d037fd5dab72f9 (patch) | |
tree | c90d0c44050b0d6da8558323f97a40f2fbcd182d | |
parent | a90a215662636fed1a2c67b49cf060e2936822f6 (diff) | |
parent | e2de16065ab0f1b3a5a56a7c805eb6ad6d9aac59 (diff) | |
download | gitea-d4035d1cb143a758463f2e3ee9d037fd5dab72f9.tar.gz gitea-d4035d1cb143a758463f2e3ee9d037fd5dab72f9.zip |
Merge pull request #830 from appleboy/patch-2001
refactor: set default order by recently star on start tab
-rw-r--r-- | models/star.go | 3 | ||||
-rw-r--r-- | models/star_test.go | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/models/star.go b/models/star.go index d7366f37b5..fd08c61fa6 100644 --- a/models/star.go +++ b/models/star.go @@ -74,7 +74,8 @@ func (repo *Repository) GetStargazers(page int) ([]*User, error) { func (u *User) GetStarredRepos(private bool) (repos []*Repository, err error) { sess := x. Join("INNER", "star", "star.repo_id = repository.id"). - Where("star.uid = ?", u.ID) + Where("star.uid = ?", u.ID). + Desc("star.id") if !private { sess = sess.And("is_private = ?", false) diff --git a/models/star_test.go b/models/star_test.go index d9717d9ec9..7b7fd516e3 100644 --- a/models/star_test.go +++ b/models/star_test.go @@ -61,8 +61,8 @@ func TestUser_GetStarredRepos(t *testing.T) { starred, err = user.GetStarredRepos(true) assert.NoError(t, err) assert.Len(t, starred, 2) - assert.Equal(t, int64(2), starred[0].ID) - assert.Equal(t, int64(4), starred[1].ID) + assert.Equal(t, int64(4), starred[0].ID) + assert.Equal(t, int64(2), starred[1].ID) } func TestUser_GetStarredRepos2(t *testing.T) { |