在特定日期时间进行延迟作业 运行
Make delayed job run at specific date time
我想通过 delayed_job
发送一些电子邮件
但是,我想在活动前后发送它们。
我担心这是否真的有效:
def one_week_before_run
AtendeeMailer.delay(run_at: '8th October 2016'.to_datetime).mudrun_about_to_start(self)
end
def thank_you_note
AtendeeMailer.delay(run_at: '18th October 2016'.to_datetime.end_of_day).thank_you(self)
end
还是我应该选择其他方法?
延迟作业选择仅在 run_at <= 当前时间时才执行的作业。参考 DJ 的查询选择工作
SELECT `delayed_jobs`.* FROM `delayed_jobs` WHERE ((run_at <= '2016-09-27 00:49:59' AND (locked_at IS NULL OR locked_at < '2016-09-27 00:24:59') OR locked_by = 'host:Madhubalans-Air pid:74314') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1
您的代码将 run_at 设置为 2016-10-18 00:00:00 和 2016-10-18 23:59:59。
所以您的代码将按照您的期望工作:)
我想通过 delayed_job
但是,我想在活动前后发送它们。
我担心这是否真的有效:
def one_week_before_run
AtendeeMailer.delay(run_at: '8th October 2016'.to_datetime).mudrun_about_to_start(self)
end
def thank_you_note
AtendeeMailer.delay(run_at: '18th October 2016'.to_datetime.end_of_day).thank_you(self)
end
还是我应该选择其他方法?
延迟作业选择仅在 run_at <= 当前时间时才执行的作业。参考 DJ 的查询选择工作
SELECT `delayed_jobs`.* FROM `delayed_jobs` WHERE ((run_at <= '2016-09-27 00:49:59' AND (locked_at IS NULL OR locked_at < '2016-09-27 00:24:59') OR locked_by = 'host:Madhubalans-Air pid:74314') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1
您的代码将 run_at 设置为 2016-10-18 00:00:00 和 2016-10-18 23:59:59。 所以您的代码将按照您的期望工作:)