Browse Source

Merge pull request #830 from appleboy/patch-2001

refactor: set default order by recently star on start tab
Andrey Nering 2 years ago
parent
commit
d4035d1cb1
2 changed files with 4 additions and 3 deletions
  1. 2 1
      models/star.go
  2. 2 2
      models/star_test.go

+ 2 - 1
models/star.go

@@ -74,7 +74,8 @@ func (repo *Repository) GetStargazers(page int) ([]*User, error) {
74 74
 func (u *User) GetStarredRepos(private bool) (repos []*Repository, err error) {
75 75
 	sess := x.
76 76
 		Join("INNER", "star", "star.repo_id = repository.id").
77
-		Where("star.uid = ?", u.ID)
77
+		Where("star.uid = ?", u.ID).
78
+		Desc("star.id")
78 79
 
79 80
 	if !private {
80 81
 		sess = sess.And("is_private = ?", false)

+ 2 - 2
models/star_test.go

@@ -61,8 +61,8 @@ func TestUser_GetStarredRepos(t *testing.T) {
61 61
 	starred, err = user.GetStarredRepos(true)
62 62
 	assert.NoError(t, err)
63 63
 	assert.Len(t, starred, 2)
64
-	assert.Equal(t, int64(2), starred[0].ID)
65
-	assert.Equal(t, int64(4), starred[1].ID)
64
+	assert.Equal(t, int64(4), starred[0].ID)
65
+	assert.Equal(t, int64(2), starred[1].ID)
66 66
 }
67 67
 
68 68
 func TestUser_GetStarredRepos2(t *testing.T) {