Skip to content
Snippets Groups Projects
Commit 47ca1f36 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

refactoring models

parent 8a91291f
No related branches found
No related tags found
No related merge requests found
......@@ -8,9 +8,7 @@ class LearningObject < ActiveRecord::Base
has_many :collection_items, as: :collectionable
has_many :collections, through: :collection_items
has_many :complaints
has_many :attachments, class_name: 'LearningObject::Attachment', dependent: :destroy
belongs_to :publisher, polymorphic: true
......@@ -18,18 +16,20 @@ class LearningObject < ActiveRecord::Base
validates_presence_of :name, :id_dspace
validates_uniqueness_of :id_dspace
scope :default_types, -> { group(:object_type).count.reject { |type, frequency| type.blank? }.map { |type, frequency| type } }
searchkick language: 'brazilian', searchable: [:name, :description, :author, :object_type]
def search_data
{
name: name,
description: description,
author: author,
object_type: object_type,
score: score,
published_at: published_at,
# publisher_id: publisher.id,
topics_name: topics.map(&:name)
name: name,
description: description,
author: author,
object_type: object_type,
score: score,
published_at: published_at,
# publisher_id: publisher.id,
topics_name: topics.map(&:name)
}
end
......@@ -49,12 +49,6 @@ class LearningObject < ActiveRecord::Base
get_metadata_value_of 'dc.object.url'
end
def self.default_types
Rails.cache.fetch("cache/object_type", expires_in: 24.hours) do
LearningObject.group(:object_type).count.reject{|type, frequency| type.blank?}.map{|type, frequency| type}
end
end
##checks if learning object link to an url.
#returns boolean
def has_url_reference?
......
......@@ -3,7 +3,6 @@ class Topic < ActiveRecord::Base
has_many :topic_relationships, foreign_key: "parent_id"
has_many :subtopics, through: :topic_relationships, source: :child
has_many :topic_highlights
has_many :highlights, through: :topic_highlights, source: :learning_object
......
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