rubyruby-on-rails-4recurrenceice-cubesucker-punch

Quick explanation of recurrence rules via ice_cube for fist of fury/ sucker punch


This is probably not the brightest question... feeling especially dense about this. I'm using a really nifty gem, Fist of Fury, to do recurring background tasks with Sucker Punch: https://github.com/facto/fist_of_fury. As the author of the gem states, recurrence rules are built using the ice cube gem https://github.com/seejohnrun/ice_cube.

He gives an example of a recurring job as such:

class SayHiJob
  include SuckerPunch::Job
  include FistOfFury::Recurrent

  recurs { minutely }

  def perform
    Rails.logger.info 'Hi!'
  end
end

I read thru the docs for Fist of Fury and Ice Cube, both as linked above, and just want to confirm my understanding...

If the latter is right, I'd love to know how to write a rule for specific time of day. Something like rule = Rule.daily(2).time_of_day(3) means I want the activity to happen every other day at 3am.


Solution

  • You should be able to use IceCube time validations like:

    hour_of_day(3).minute_of_hour(15).second_of_minute(0)

    Hope that helps!