GetLikings() & GetFollowers() now return count too
Cette révision appartient à :
Parent
0fea1df5c1
révision
70899dc490
1 fichiers modifiés avec 4 ajouts et 2 suppressions
|
@ -260,17 +260,19 @@ func (u *User) ToJSON() UserJSON {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLikings : Gets who is followed by the user
|
// GetLikings : Gets who is followed by the user
|
||||||
func (u *User) GetLikings() {
|
func (u *User) GetLikings() int {
|
||||||
var liked []User
|
var liked []User
|
||||||
ORM.Joins("JOIN user_follows on user_follows.following=?", u.ID).Where("users.user_id = user_follows.user_id").Group("users.user_id").Find(&liked)
|
ORM.Joins("JOIN user_follows on user_follows.following=?", u.ID).Where("users.user_id = user_follows.user_id").Group("users.user_id").Find(&liked)
|
||||||
u.Likings = liked
|
u.Likings = liked
|
||||||
|
return len(u.Likings)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFollowers : Gets who is following the user
|
// GetFollowers : Gets who is following the user
|
||||||
func (u *User) GetFollowers() {
|
func (u *User) GetFollowers() int {
|
||||||
var likings []User
|
var likings []User
|
||||||
ORM.Joins("JOIN user_follows on user_follows.user_id=?", u.ID).Where("users.user_id = user_follows.following").Group("users.user_id").Find(&likings)
|
ORM.Joins("JOIN user_follows on user_follows.user_id=?", u.ID).Where("users.user_id = user_follows.following").Group("users.user_id").Find(&likings)
|
||||||
u.Followers = likings
|
u.Followers = likings
|
||||||
|
return len(u.Followers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFollow : Makes a user follow another
|
// SetFollow : Makes a user follow another
|
||||||
|
|
Référencer dans un nouveau ticket