title: Dynamically generating new scheduled tasks using rufus scheduler
body: <p>I'm looking to dynamically generate new scheduler tasks because the number of tasks I have depends on the size of the database. The larger the database gets, the more tasks I will need, and I'm wondering if there is any way for me to write my Rails app to do this automatically rather than having to manually go in and add more tasks each time. 
  Any ideas? </p>
  
  <p>My rufus scheduler .rb file has blocks like </p>
  
  <pre><code>scheduler.every("7d") do 
      size = Rails.cache.fetch("size")
      get_data_portion(0, size)
  end
  
  scheduler.every("7d") do 
      size = Rails.cache.fetch("size")
      get_data_portion(1, size)
  end
  </code></pre>
  
  <p>where size determines how big of a section of my database I am querying, and the first argument (0 and 1) determines exactly what section of the database it is querying. Currently, the size is determined after seeing how large the database is currently, breaking it into even chunks, and then having that many scheduler events to correspond with each chunk of data. </p>
  
  <p>The next time the scheduler is run, however, the database may have increased so much that the get_data_portion method would be querying too much data if I stayed with the same amount of scheduler events. Because of this, I was hoping to be able to create more scheduler events, but without having to manually do it each time. Does this make my inquiry clearer?</p>