Skip to content
Snippets Groups Projects
Commit d85e5fb4 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

add score generator for learning objects

parent 6151e740
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ class LearningObject ...@@ -5,7 +5,7 @@ class LearningObject
attr_accessor :id, :id_dspace, :rid, :name, :author, :description, attr_accessor :id, :id_dspace, :rid, :name, :author, :description,
:published_at, :thumbnail, :created_at, :last_modified, :published_at, :thumbnail, :created_at, :last_modified,
:type, :grade_level, :bitstreams, :metadata, :likes, :views, :type, :grade_level, :bitstreams, :metadata, :likes, :views,
:downloads, :subjects, :attributes :downloads, :subjects, :attributes, :score
validates_presence_of :name, :created_at, :type, :likes, :views, :downloads validates_presence_of :name, :created_at, :type, :likes, :views, :downloads
validates_numericality_of :likes, greater_than_or_equal_to: 0 validates_numericality_of :likes, greater_than_or_equal_to: 0
...@@ -82,7 +82,8 @@ class LearningObject ...@@ -82,7 +82,8 @@ class LearningObject
{ {
likes: 0, likes: 0,
views: 0, views: 0,
downloads: 0 downloads: 0,
score: 0
# Setting this default value wont allow created_at to be set trough the constructor # Setting this default value wont allow created_at to be set trough the constructor
# created_at: DateTime.new # created_at: DateTime.new
} }
......
...@@ -193,7 +193,7 @@ module OrientDb ...@@ -193,7 +193,7 @@ module OrientDb
query = "SELECT * FROM (" + query + ") WHERE " + fetch_types(params[:type]) unless params[:type].blank? query = "SELECT * FROM (" + query + ") WHERE " + fetch_types(params[:type]) unless params[:type].blank?
query = "SELECT * FROM (" + query + ") WHERE " + fetch_year(params[:year]) unless params[:year].blank? query = "SELECT * FROM (" + query + ") WHERE " + fetch_year(params[:year]) unless params[:year].blank?
query = "SELECT * FROM (" + query + ") ORDER BY #{order}" unless order.nil? query = "SELECT * FROM (" + query + ") ORDER BY #{order}" unless order.nil?
query = "SELECT @rid.asString(), last_modified FROM (" + query + ")"# ORDER BY score DESC query = "SELECT @rid.asString(), last_modified FROM (" + query + ") ORDER BY score DESC"
learning_objects_hash = connection.query query, limit: 10000 learning_objects_hash = connection.query query, limit: 10000
# return only rids with their modification time # return only rids with their modification time
...@@ -239,23 +239,23 @@ module OrientDb ...@@ -239,23 +239,23 @@ module OrientDb
qry qry
end end
def count_likes(learning_object)
get_in_edges_count "Likes", learning_object.id
end
def count_views(learning_object)
get_in_edges_count "Views", learning_object.id
end
private private
def accepted_properties def accepted_properties
['thumbnail'] ['thumbnail', 'score']
end end
def odb_class def odb_class
"LearningObject" "LearningObject"
end end
def count_likes(learning_object)
get_in_edges_count "Likes", learning_object.id
end
def count_views(learning_object)
get_in_edges_count "Views", learning_object.id
end
end end
end end
...@@ -5,8 +5,16 @@ ...@@ -5,8 +5,16 @@
# on all of the machines, including database's configs and # on all of the machines, including database's configs and
# environment type (development, test, production). # environment type (development, test, production).
# #
:pidfile: ./shared/pids/sidekiq.pid
:logfile: ./shared/logs/sidekiq.log
:queues:
- default
- score
- [high_priority, 2]
# :daemon: true
development: &development development: &development
concurrency: 5
host: localhost host: localhost
port: 6379 port: 6379
......
...@@ -26,11 +26,7 @@ namespace :thumbnail do ...@@ -26,11 +26,7 @@ namespace :thumbnail do
break if items.empty? break if items.empty?
items.each do |item| items.each do |item|
if item.thumbnail.nil? ThumbnailGeneratorWorker.perform_async(item.id) if item.thumbnail.blank?
ThumbnailGeneratorWorker.perform_async(item.id)
elsif item.thumbnail.empty?
ThumbnailGeneratorWorker.perform_async(item.id)
end
end end
# Increment offset, to get new items on next iteration # Increment offset, to get new items on next iteration
......
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