Skip to content

Commit

Permalink
Merge pull request #830 from appleboy/patch-2001
Browse files Browse the repository at this point in the history
refactor: set default order by recently star on start tab
  • Loading branch information
andreynering authored Feb 4, 2017
2 parents a90a215 + e2de160 commit d4035d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion models/star.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions models/star_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d4035d1

Please sign in to comment.