refactor: set default order by recently star.
This commit is contained in:
parent
bf6f61cc69
commit
e2de16065a
|
@ -74,7 +74,8 @@ func (repo *Repository) GetStargazers(page int) ([]*User, error) {
|
||||||
func (u *User) GetStarredRepos(private bool) (repos []*Repository, err error) {
|
func (u *User) GetStarredRepos(private bool) (repos []*Repository, err error) {
|
||||||
sess := x.
|
sess := x.
|
||||||
Join("INNER", "star", "star.repo_id = repository.id").
|
Join("INNER", "star", "star.repo_id = repository.id").
|
||||||
Where("star.uid = ?", u.ID)
|
Where("star.uid = ?", u.ID).
|
||||||
|
Desc("star.id")
|
||||||
|
|
||||||
if !private {
|
if !private {
|
||||||
sess = sess.And("is_private = ?", false)
|
sess = sess.And("is_private = ?", false)
|
||||||
|
|
|
@ -61,8 +61,8 @@ func TestUser_GetStarredRepos(t *testing.T) {
|
||||||
starred, err = user.GetStarredRepos(true)
|
starred, err = user.GetStarredRepos(true)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, starred, 2)
|
assert.Len(t, starred, 2)
|
||||||
assert.Equal(t, int64(2), starred[0].ID)
|
assert.Equal(t, int64(4), starred[0].ID)
|
||||||
assert.Equal(t, int64(4), starred[1].ID)
|
assert.Equal(t, int64(2), starred[1].ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUser_GetStarredRepos2(t *testing.T) {
|
func TestUser_GetStarredRepos2(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue