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