diff --git a/app/serializers/collection_min_serializer.rb b/app/serializers/collection_min_serializer.rb index 55bbf3352934110c3edc83e01e5547f9b5977134..4dbb788e9d7f74626792a3cecf90abcfbce0b786 100644 --- a/app/serializers/collection_min_serializer.rb +++ b/app/serializers/collection_min_serializer.rb @@ -1,6 +1,12 @@ class CollectionMinSerializer < ActiveModel::Serializer - cache key: 'collection', expires_in: 4.hours - attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :review_average, :thumbnail + cache key: 'collection', expires_in: 4.hours, except: [:likes_count, :liked] + + def liked + object.liked? current_user + end + + + attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :review_average, :thumbnail has_many :tags has_many :subjects has_many :educational_stages diff --git a/app/serializers/collection_serializer.rb b/app/serializers/collection_serializer.rb index 1213c0d677590d880cc4e96bb7ea516cdece37ac..ef5a2dedccce4860bb56f5c4946bef1d7e2cc562 100644 --- a/app/serializers/collection_serializer.rb +++ b/app/serializers/collection_serializer.rb @@ -1,6 +1,11 @@ class CollectionSerializer < ActiveModel::Serializer - cache key: 'collection', expires_in: 4.hours - attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :review_average, :thumbnail + cache key: 'collection', expires_in: 4.hours, except: [:likes_count, :liked] + + def liked + object.liked? current_user + end + + attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :review_average, :thumbnail has_many :tags has_many :subjects has_many :educational_stages