Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

GetLikings() & GetFollowers() now return count too

Cette révision appartient à :
kilo 2017-11-16 19:18:29 +01:00 révisé par GitHub
Parent 0fea1df5c1
révision 70899dc490
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23

Voir le fichier

@ -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