mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-07-13 21:44:32 +08:00
ADD users/hovercard api
This commit is contained in:
@@ -6,6 +6,7 @@ module Watchable
|
||||
has_many :watcher_users, through: :watchers, source: :user, validate: false
|
||||
|
||||
scope :watched_by, -> (user_id) { includes(:watchers).where(watchers: { user_id: user_id }) }
|
||||
scope :following, -> (user_id) { watched_by }
|
||||
end
|
||||
|
||||
def watched?(watchable)
|
||||
@@ -21,6 +22,24 @@ module Watchable
|
||||
obj.destroy! if obj.present?
|
||||
end
|
||||
|
||||
# 我正在关注的、我追随的
|
||||
def following
|
||||
User.following(self.id)
|
||||
end
|
||||
|
||||
def following_count
|
||||
following.size
|
||||
end
|
||||
|
||||
# 关注我的、我的粉丝、我的追随者
|
||||
def followers
|
||||
watcher_users
|
||||
end
|
||||
|
||||
def followers_count
|
||||
followers.size
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user