Module: Coupler::Extensions::Jobs

Defined in:
lib/coupler/extensions/jobs.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/coupler/extensions/jobs.rb', line 4

def self.registered(app)
  app.get "/jobs" do
    @jobs = Models::Job.order("id DESC")
    erb 'jobs/index'.to_sym
  end

  app.get "/jobs/count" do
    content_type :json
    [200, [Models::Job.filter(:completed_at => nil).count.to_json]]
  end

  app.get "/jobs/:id/progress" do
    content_type :text
    @job = Models::Job[:id => params[:id]]
    [200, [{ :completed => @job.completed, :total => @job.total }.to_json]]
  end
end