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

fix mainPage highlights task

parent 7cfae629
No related branches found
No related tags found
No related merge requests found
namespace :mainPage do namespace :mainPage do
desc "Generate the MainPage" desc "Generate the MainPage"
task :highlights => :environment do task :highlights => :environment do
repository = Portalmec::Application.repository include RepositoriesProxy
# repository = Portalmec::Application.repository
puts 'Generate the main page subject highlights' puts 'Generate the main page subject highlights'
general_highlights = Array.new general_highlights = Array.new
subjects = repository.for(:subject).all subjects = subject_repository.all
subjects.each do |subject| subjects.each do |subject|
# select all the learning objects about that subject # select all the learning objects about that subject
objects = subject.learning_objects objects = subject.learning_objects
...@@ -20,17 +21,17 @@ namespace :mainPage do ...@@ -20,17 +21,17 @@ namespace :mainPage do
# add the object to the subject highlight # add the object to the subject highlight
puts subject.name puts subject.name
repository.for(:subject).update(subject.id,'set','highlights','[]') subject_repository.update(subject.id,'set','highlights','[]')
objects.each do |object| objects.each do |object|
repository.for(:subject).update(subject.id,'add','highlights',object.name) subject_repository.update(subject.id,'add','highlights',object.name)
end end
end end
puts 'Generating the main page highlights' puts 'Generating the main page highlights'
mainPage = repository.for(:mainPage).all.first mainPage = main_page_repository.all.first
rid = mainPage['@rid'] rid = mainPage['@rid']
repository.for(:mainPage).update(rid,'set','highlights','[]') main_page_repository.update(rid,'set','highlights','[]')
general_highlights.each do |general_highlight| general_highlights.each do |general_highlight|
repository.for(:mainPage).update(rid,'add','highlights',general_highlight.name) main_page_repository.update(rid,'add','highlights',general_highlight.name)
end end
end 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