Commit 92747293d7a86a7a13351236c46c8c9e9d66e852

Authored by Victor Costa
1 parent fa512fa6

virtuoso: added action to force harvest from start

plugins/virtuoso/controllers/virtuoso_plugin_admin_controller.rb
@@ -15,7 +15,7 @@ class VirtuosoPluginAdminController < AdminController @@ -15,7 +15,7 @@ class VirtuosoPluginAdminController < AdminController
15 15
16 def force_harvest 16 def force_harvest
17 harvest = VirtuosoPlugin::DspaceHarvest.new(environment) 17 harvest = VirtuosoPlugin::DspaceHarvest.new(environment)
18 - harvest.start 18 + harvest.start(params[:from_start])
19 session[:notice] = _('Harvest started') 19 session[:notice] = _('Harvest started')
20 redirect_to :action => :index 20 redirect_to :action => :index
21 end 21 end
plugins/virtuoso/lib/virtuoso_plugin/dspace_harvest.rb
@@ -49,8 +49,13 @@ class VirtuosoPlugin::DspaceHarvest @@ -49,8 +49,13 @@ class VirtuosoPlugin::DspaceHarvest
49 puts "ending harvest #{harvest_time}" 49 puts "ending harvest #{harvest_time}"
50 end 50 end
51 51
52 - def start 52 + def start(from_start = false)
53 if find_job.empty? 53 if find_job.empty?
  54 + if from_start
  55 + settings.last_harvest = nil
  56 + settings.save!
  57 + end
  58 +
54 job = VirtuosoPlugin::DspaceHarvest::Job.new(@environment.id) 59 job = VirtuosoPlugin::DspaceHarvest::Job.new(@environment.id)
55 Delayed::Job.enqueue(job) 60 Delayed::Job.enqueue(job)
56 end 61 end
plugins/virtuoso/test/functional/virtuoso_plugin_admin_controller_test.rb
@@ -35,4 +35,11 @@ class VirtuosoPluginAdminControllerTest < ActionController::TestCase @@ -35,4 +35,11 @@ class VirtuosoPluginAdminControllerTest < ActionController::TestCase
35 assert harvest.find_job.present? 35 assert harvest.find_job.present?
36 end 36 end
37 37
  38 + should 'force harvest from start' do
  39 + get :force_harvest, :from_start => true
  40 + harvest = VirtuosoPlugin::DspaceHarvest.new(environment)
  41 + assert harvest.find_job.present?
  42 + assert_equal nil, harvest.settings.last_harvest
  43 + end
  44 +
38 end 45 end
plugins/virtuoso/views/virtuoso_plugin_admin/index.html.erb
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 <%= _('Running...') %> 29 <%= _('Running...') %>
30 <% else %> 30 <% else %>
31 <%= button :next, _('Force harvest'), :action => :force_harvest %> 31 <%= button :next, _('Force harvest'), :action => :force_harvest %>
  32 + <%= button :next, _('Force harvest from start'), :action => :force_harvest, :from_start => true %>
32 <% end %> 33 <% end %>
33 </div> 34 </div>
34 </div> 35 </div>