lib/sidekiq-status/worker.rb in sidekiq-status-0.7.0 vs lib/sidekiq-status/worker.rb in sidekiq-status-0.8.0

- old
+ new

@@ -25,17 +25,19 @@ # (inspired by resque-status) # @param Fixnum number of tasks done # @param String optional message # @return [String] def at(num, message = nil) - total(100) if retrieve(:total).nil? - store(at: num, message: message) + @_status_total = 100 if @_status_total.nil? + pct_complete = ((num / @_status_total.to_f) * 100).to_i rescue 0 + store(at: num, total: @_status_total, pct_complete: pct_complete, message: message) end # Sets total number of tasks # @param Fixnum total number of tasks # @return [String] def total(num) + @_status_total = num store(total: num) end end