-
-
Save jcap49/785612f63b8cc0afedea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# text_message.rb --> TextMessage model | |
class TextMessage < ActiveRecord::Base | |
# below: a class method to execute a worker | |
# the IronWorker API takes a few fun params split into | |
# two distinct sections: the first part of the payload | |
# handles any params that are useful for the worker during | |
# runtime - for example, :database is used to pass in | |
# database credentials for the worker to use; | |
# the second part of the payload (separated by | |
# a new hash) is used to define settings for the worker itself | |
def self.execute_text_message_worker(text_message_id, send_time, user_id) | |
iron_worker = IronWorkerNG::Client.new | |
@text_message_worker = iron_worker.schedules.create("Master", { | |
:text_message_id => text_message_id, | |
:user_id => user_id, | |
:database => Rails.configuration.database_configuration[Rails.env], | |
},{ | |
:start_at => send_time + 5.hours, | |
:run_every => 3600 * 24, | |
}) | |
TextMessage.save_text_message_schedule_id(@text_message_worker.id, text_message_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment