diff --git a/app/views/periodictask/_form.html.erb b/app/views/periodictask/_form.html.erb index d253471..6c701aa 100644 --- a/app/views/periodictask/_form.html.erb +++ b/app/views/periodictask/_form.html.erb @@ -28,7 +28,7 @@ <%= l(:no_members_in_project) %> <% end %>
-<%= label(:periodictask, :interval_number, l(:label_interval)) %><%= f.text_field :interval_number, :required=> true, :size => 3 %> <%= select 'periodictask', 'interval_units', Periodictask::INTERVAL_UNITS %>
+<%= label(:periodictask, :interval_number, l(:label_interval)) %><%= f.number_field :interval_number, :value => 1, :required => true, :min => 1 %> <%= select 'periodictask', 'interval_units', Periodictask::INTERVAL_UNITS %>
<%= label(:periodictask, :tracker_id, "Tracker") %><%= collection_select("periodictask", "tracker_id", @project.trackers, :id, :name ) %>
<%= label(:periodictask, :set_start_date, l(:label_set_start_date)) %><%= f.check_box :set_start_date %>
<%= label(:periodictask, :due_date, l(:label_due_date)) %><%= f.text_field :due_date_number, :size => 3 %><%= select 'periodictask', 'due_date_units', Periodictask::INTERVAL_UNITS %>
diff --git a/lib/scheduled_tasks_checker.rb b/lib/scheduled_tasks_checker.rb index bd08580..9cc9ea9 100644 --- a/lib/scheduled_tasks_checker.rb +++ b/lib/scheduled_tasks_checker.rb @@ -39,8 +39,10 @@ def self.checktasks! if units.downcase == "business_day" task.next_run_date = task.interval_number.business_day.after(now) else - interval_steps = ((now - task.next_run_date) / interval.send(unit_to_use)).ceil - task.next_run_date += (interval * interval_steps).send(units.downcase) + if (interval > 0) + interval_steps = ((now - task.next_run_date) / interval.send(units.downcase)).ceil + task.next_run_date += (interval * interval_steps).send(units.downcase) + end end task.save end