Resque::Plugins::Status::Hash#pct_complete can explode - I'm happy to fix
Closed this issue · 1 comments
joncooper commented
def pct_complete
case status
when 'completed' then 100
when 'queued' then 0
else
t = (total == 0 || total.nil?) ? 1 : total
(((num || 0).to_f / t.to_f) * 100).to_i
end
end
If the user accidentally sets total
to a string by doing something like at(1, "This is my status")
, this method will explode by trying to call NaN.to_i
, which will cause the web app's Statuses tab to fail.
I'm happy to patch if you tell me how you'd like it done:
- Guard on at()
- Guard on pct_complete which raises an Exception
- Something else
Jon
quirkey commented
Guarding on at()
seems like the right thing to me. Will accept a patch.