From fbcfcd1fa874bcace9bef66947a4b527f85a54fb Mon Sep 17 00:00:00 2001
From: Lucas Gabriel Lima <lgl15@inf.ufpr.br>
Date: Thu, 12 May 2016 11:48:34 -0300
Subject: [PATCH] create highlights method for LearningObject

---
 app/models/learning_object.rb | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb
index 5af6a084..a6ec12fc 100644
--- a/app/models/learning_object.rb
+++ b/app/models/learning_object.rb
@@ -131,4 +131,19 @@ class LearningObject < ActiveRecord::Base
   def user_category
     publisher.try('user_category')
   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)
+    return highlights
+  end
 end
-- 
GitLab