Question

I have an app that scrapes data from a webpage. This scraping takes about 5-10 minutes and so it is not a very user-friendly experience. I would like for a user to be able to set up and schedule a time for the page to be scraped and then once finished send an email them alerting them.

So is there a way to set up rufus-scheduler to take user input into account? If not, how should I go about this?

Was it helpful?

Solution

Homework question, grrr. http://www.catb.org/~esr/faqs/smart-questions.html#idp54052224

Let's say you have a form that vaguely looks like:

<form action="/stupid/" method="POST">
  <input type="text" name="schedule" />
</form>

it's POSTing to the StupidController:

class StupidController < ApplicationController

  # POST requests for /stupid/ come here
  #
  def create

    # expects something like "5m" or "10d"
    s = params[:schedule]

    @job_id =
      Rufus::Scheduler.singleton.in(s) do
        # do the job...
      end
  end
end

The controller extracts the user-chosen schedule from the form data and then schedules a job.

If that answer goes above your head like the ones at Can I schedule controller methods in rails using rufus-scheduler? then you should really invest time learning to learn instead of asking people to do your work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top