mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
#5 Remove duplicated method from user serializer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class UserSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :id, :name, :email, :avatar, :followed, :posts_count, :likes_count, :stars_count, :follows_count,
|
||||
attributes :id, :name, :email, :avatar, :followed, :posts_count, :likes_count, :follows_count,
|
||||
:followers_count,
|
||||
|
||||
def followed
|
||||
@@ -16,12 +16,8 @@ class UserSerializer < ActiveModel::Serializer
|
||||
object.likes.count
|
||||
end
|
||||
|
||||
def stars_count
|
||||
object.stars.count
|
||||
end
|
||||
|
||||
def follows_count
|
||||
FollowRelation.where(user_id: object.id).count
|
||||
object.stars.count
|
||||
end
|
||||
|
||||
def followers_count
|
||||
|
||||
Reference in New Issue
Block a user