Migrate to new follows storage

This commit is contained in:
2019-11-19 13:51:54 +09:00
parent 99f5ae1b4f
commit 803d303420
14 changed files with 237 additions and 241 deletions

View File

@ -42,51 +42,12 @@ func (user *User) Inventory() *Inventory {
return inventory
}
// Follows returns the list of user follows.
func (user *User) Follows() *UserFollows {
follows, _ := GetUserFollows(user.ID)
return follows
}
// Notifications returns the list of user notifications.
func (user *User) Notifications() *UserNotifications {
notifications, _ := GetUserNotifications(user.ID)
return notifications
}
// Followers ...
func (user *User) Followers() []*User {
var followerIDs []string
for list := range StreamUserFollows() {
if list.Contains(user.ID) {
followerIDs = append(followerIDs, list.UserID)
}
}
usersObj := DB.GetMany("User", followerIDs)
users := make([]*User, len(usersObj))
for i, obj := range usersObj {
users[i] = obj.(*User)
}
return users
}
// FollowersCount ...
func (user *User) FollowersCount() int {
count := 0
for list := range StreamUserFollows() {
if list.Contains(user.ID) {
count++
}
}
return count
}
// DraftIndex ...
func (user *User) DraftIndex() *DraftIndex {
draftIndex, _ := GetDraftIndex(user.ID)