I would like to implement irregular batch processing (only when the request was made).(Use a gem like whenever.)

Asked 5 months ago, Updated 5 months ago, 12 views

We would like to implement the following batch processing.
However, it is not a regular thing like once a day, but only when a request is made.
Therefore, on many days, batch processing may run five times a day, or on the contrary, it may not run once a day.

 Enter the date and time you want to run from the screen and submit a request
Batch processing starts at that time of day

To achieve periodic batch processing in Rails whenever seemed good.

However, as mentioned above, I was not sure what kind of design I should use to achieve irregular batch processing.

Also, I thought about how to register with cron every hour to check if there is a request or not, but I think it's not a very good design, so if there's any other good way, I'd like to design based on it.

Thank you for your cooperation.

以下 I would like to make it happen with the following image.

#params[:batch_requests] contains multiple dates and times

every params [:batch_requests] do

Also, I have a question for you.
Thank you for your understanding.

ruby-on-rails ruby

2022-09-30 11:51

1 Answers

I would use ActiveJob.

As an image, this is what it looks like.

class BatchController <ApplicationController
  def create(batch_at)

Since whenever is cron, I don't think it's suitable for irregular execution, but I wonder what it is like.

2022-09-30 11:51

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.