如何在ruby应用程序中定制cron作业?

如何在ruby应用程序中定制cron作业?,ruby,cron,padrino,Ruby,Cron,Padrino,我一直在用padrino ruby框架开发后端,我想构建一个cron作业 这就是我所做的 gem'where',:require=>false whenverize. 内部进度表.rb every 1.minute do rake "cronjob" end /tasks/cronjob.rake 在这里,我添加了自定义任务。这将是很长的时间来添加在这里 所以我只写了发生错误的部分 performances = Performance.left_join(:slots, id:

我一直在用padrino ruby框架开发后端,我想构建一个cron作业

这就是我所做的

  • gem'where',:require=>false
  • whenverize.
内部进度表.rb

 every 1.minute do
    rake "cronjob"
 end
/tasks/cronjob.rake

在这里,我添加了自定义任务。这将是很长的时间来添加在这里

所以我只写了发生错误的部分

performances = Performance.left_join(:slots, id: :slot_id).where(Sequel.~(status: ModelA::Api.settings.pending),Sequel[:slots][:from]>oneweekbefore,Sequel[:slots][:to]<onemonthafter+1.day)
....

begin
  data = {}
  data[:from] = "** <postmaster@**.mailgun.org>"
  data[:to] = email
  data[:subject] = subject
  data[:html] = render 'mails/sendemailbasedontime',:locals => { :data => localdata }
  RestClient.post GigabitArtist::Api.settings.mailgun_domain, data
    rescue => exception
      puts exception.inspect
    end
end
当然,这个查询是在另一个.rb文件中测试的,我使用原始sql进行了测试。例如,我在test.rb控制器的get request hander中测试了这个任务。它确实工作得很好 我想知道我是否可以在任务内部使用渲染功能。 我找了一整天这个问题,但没有成功。 任何建议都会对我大有帮助。
非常感谢。

正如弃用警告所述,您正在向筛选器方法传递多个参数。最简单的修复方法是分别为每个参数调用筛选器方法:

performances = Performance.
  left_join(:slots, id: :slot_id).
  exclude(status: ModelA::Api.settings.pending).
  where(Sequel[:slots][:from]>oneweekbefore).
  where(Sequel[:slots][:to]<onemonthafter+1.day)
性能=性能。
左连接(:插槽,id::插槽\U id)。
排除(状态:ModelA::Api.settings.pending)。
其中(续集[:slots][:from]>1周前)。
其中(续集[:插槽][:到]
performances = Performance.
  left_join(:slots, id: :slot_id).
  exclude(status: ModelA::Api.settings.pending).
  where(Sequel[:slots][:from]>oneweekbefore).
  where(Sequel[:slots][:to]<onemonthafter+1.day)