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

Merge branch 'feature-highlights' of gitlab.c3sl.ufpr.br:portalmec/portalmec...

Merge branch 'feature-highlights' of gitlab.c3sl.ufpr.br:portalmec/portalmec into feature-highlights
parents c3d334f6 36ace36f
No related branches found
No related tags found
No related merge requests found
# == Schema Information # == Schema Information
# #
# Table name: learning_objects # Table name: learning_objects
# #
...@@ -60,6 +60,8 @@ class LearningObject < ActiveRecord::Base ...@@ -60,6 +60,8 @@ class LearningObject < ActiveRecord::Base
default_scope { includes(:object_type, :attachment, :attachments).order(score: :desc) } default_scope { includes(:object_type, :attachment, :attachments).order(score: :desc) }
scope :missing_thumbnail, ->() { where(thumbnail_file_name: nil) } scope :missing_thumbnail, ->() { where(thumbnail_file_name: nil) }
scope :this_week, -> { where('created_at >= ?', 1.week.ago) }
scope :this_month, -> { where('created_at >= ?', 1.month.ago) }
searchkick language: 'brazilian', match: :word_start, searchable: [:name, :description, :author, :object_type], callbacks: :async searchkick language: 'brazilian', match: :word_start, searchable: [:name, :description, :author, :object_type], callbacks: :async
...@@ -136,4 +138,19 @@ class LearningObject < ActiveRecord::Base ...@@ -136,4 +138,19 @@ class LearningObject < ActiveRecord::Base
def user_category def user_category
publisher.try('user_category') publisher.try('user_category')
end end
#period is either :week or :month
def self.highlights(period, limit)
if period == :week
los = LearningObject.this_week
elsif period == :month
los = LearningObject.this_month
else
los = LearningObject.all
end
los.order(score: :desc)
highlights = los.first(limit)
highlights
end
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