Skip to content
Snippets Groups Projects
Commit c55103aa authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

solve conflicts

parents be2eb56a 662d2c9b
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ class Collection < ApplicationRecord
has_many :learning_objects, through: :collection_items, source: :collectionable, source_type: 'LearningObject'
has_many :collection_items
belongs_to :owner, polymorphic: true
belongs_to :owner, polymorphic: true, counter_cache: true
validates :name, :owner, presence: true
validates_inclusion_of :privacy, in: %w(public private), message: 'Privacy must be public or private'
......
......@@ -52,7 +52,7 @@ class LearningObject < ApplicationRecord
has_many :collections, through: :collection_items
has_many :attachments, class_name: 'LearningObject::Attachment', autosave: true # autosave to allow import
belongs_to :publisher, polymorphic: true
belongs_to :publisher, polymorphic: true, counter_cache: true
belongs_to :language
belongs_to :license
belongs_to :object_type
......
......@@ -16,7 +16,7 @@ class Like < ApplicationRecord
include Trackable
belongs_to :likeable, polymorphic: true, counter_cache: true
belongs_to :user
belongs_to :user, counter_cache: true
validates_presence_of :user, :likeable
validates :user_id, uniqueness: { scope: [:likeable_id, :likeable_type] }
......
class CollectionSerializer < ActiveModel::Serializer
cache key: 'collection', expires_in: 4.hours
attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score
attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :review_average, :thumbnail
has_many :tags
has_many :subjects
has_many :educational_stages
......
class UserSerializer < ActiveModel::Serializer
cache key: 'user', expires_in: 4.hours
attributes :id, :email, :name, :description, :created_at, :updated_at, :role_ids, :institution_ids, :avatar
# has_many :roles
# has_many :institutions
attributes :id, :email, :provider, :name, :description, :role_ids, :institution_ids, :avatar, :likes_count, :follows_count, :learning_objects_count, :collections_count, :created_at, :updated_at
end
class AddCountsToUser < ActiveRecord::Migration[5.0]
def change
add_column :users, :likes_count, :integer, default: 0
add_column :users, :learning_objects_count, :integer, default: 0
add_column :users, :collections_count, :integer, default: 0
end
end
class AddReviewAverageToCollection < ActiveRecord::Migration[5.0]
def change
add_column :collections, :review_average, :float, default: 0.0
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment