diff --git a/app/assets/stylesheets/application/welcome.scss b/app/assets/stylesheets/application/welcome.scss index beafcb4b5be3d566d5400d8625e07d760e493c7e..c52bb26f7ba5c9177f0ff5264488ce0158b3d05c 100644 --- a/app/assets/stylesheets/application/welcome.scss +++ b/app/assets/stylesheets/application/welcome.scss @@ -7,7 +7,7 @@ color: white; } -.mainpage-subjects, .mainpage-highlights { +.mainpage-highlights { margin-top: 30px; h2 { @@ -15,7 +15,7 @@ } } -.mainpage-subject-element { +.mainpage-highlight-element { width: 250px; h4 { diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index c84caefc1d98ec7922147ec0cc4939679474c0c0..6bdd3cfb559114b202fb340f88a003f22fbbbad6 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -37,11 +37,11 @@ class SearchController < ApplicationController def autocomplete begin auto = AutocompleteService.new - query = params["q"] || "" + query = params['q'] || '' json_data = auto.query(query) render text: json_data rescue - render text: "[]" + render text: '[]' end end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9881ea47b95e7af858f16935894b86ba1ff54b83..af71f7f552580aa6fdeb448b195a38a796f30a5b 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -11,9 +11,7 @@ class WelcomeController < ApplicationController learning_object_repository.find(id) end - @subjects = subject_repository.all_from_offset_to_limit 0, 10 - @subjects.reject!{|s| s.highlights.blank?} - @subjects = @subjects.take(6) + @highlights = learning_object_repository.all_by_score_from_offset_to_limit 0, 6 end def faq diff --git a/app/repositories/orient_db/learning_object_repository.rb b/app/repositories/orient_db/learning_object_repository.rb index 4c2ebfa26262b71faa62a357a7bb89a045ce65d7..611e35e4ed08b046039c448e9d8bc2f78046c016 100644 --- a/app/repositories/orient_db/learning_object_repository.rb +++ b/app/repositories/orient_db/learning_object_repository.rb @@ -121,6 +121,11 @@ module OrientDb [] end + def all_by_score_from_offset_to_limit(offset, limit) + objects_hash = connection.query "SELECT FROM LearningObject ORDER BY score DESC LIMIT #{limit} SKIP #{offset}", limit: limit + objects = build_objects(objects_hash) || [] + end + def get_subjects(learning_object) result = get_edges_end("IsAbout", "out", learning_object.id) subject_repository.build_objects(result) @@ -290,4 +295,4 @@ module OrientDb end end -end \ No newline at end of file +end diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 5fbbfea8f526cfecef3852fa6c6058e7949cb285..55397cf96cec06df5aaf5aba25cf3f091b688b73 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -66,15 +66,14 @@ <% end %> </div> -<div class="row mainpage-subjects"> +<div class="row mainpage-highlights"> <div class="col-md-12"> - <% unless @subjects.blank? %> + <% unless @highlights.blank? %> <div class="row learning-object-columns"> <h2>Destaque</h2> - <% @subjects.each do |subject| %> - <div class="row mainpage-subject-element"> - <h4><b><%= subject.name %></b></h4> - <%= render subject.highlights.first, orientation: 'vertical' unless subject.highlights.first.nil? %> + <% @highlights.each do |highlight| %> + <div class="row mainpage-highlight-element"> + <%= render highlight, orientation: 'vertical' %> <p class="more"> <a href="#">Ver Mais</a> </p>