Albirew/nyaa-pantsu
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
Signature inconnue de Forgejo
ID de la clé GPG: 4AEE18F83AFDEB23
1 fichiers modifiés avec 4 ajouts et 2 suppressions

Voir le fichier

@ -260,17 +260,19 @@ func (u *User) ToJSON() UserJSON {
}
// GetLikings : Gets who is followed by the user
func (u *User) GetLikings() {
func (u *User) GetLikings() int {
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)
u.Likings = liked
return len(u.Likings)
}
// GetFollowers : Gets who is following the user
func (u *User) GetFollowers() {
func (u *User) GetFollowers() int {
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)
u.Followers = likings
return len(u.Followers)
}
// SetFollow : Makes a user follow another