9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/steve/interface.rb', line 9
def call(env)
@req = Rack::Request.new(env)
case env['PATH_INFO'].to_s
when '/', ''
[200, {'Content-type' => 'text/html'}, [haml(:index)]]
when /failed/
@jobs = Steve::ArchivedJob.failed.asc.paginate(:page => @req.params['page'], :per_page => 50)
[200, {'Content-type' => 'text/html'}, [haml(:failed)]]
when /completed/
@jobs = Steve::ArchivedJob.completed.asc.paginate(:page => @req.params['page'], :per_page => 50)
[200, {'Content-type' => 'text/html'}, [haml(:completed)]]
when /archived\/object/
@jobs = Steve::ArchivedJob.where(:associated_object_type => @req.params['type'], :associated_object_id => @req.params['id']).order('created_at desc').limit(25)
[200, {'Content-type' => 'text/html'}, [haml(:object)]]
when /archived\/view/
@job = Steve::ArchivedJob.find(@req.params['id'])
[200, {'Content-type' => 'text/html'}, [haml(:view)]]
when /object/
@jobs = Steve::QueuedJob.where(:associated_object_type => @req.params['type'], :associated_object_id => @req.params['id']).order('created_at desc').limit(25)
[200, {'Content-type' => 'text/html'}, [haml(:object)]]
when /view/
@job = Steve::QueuedJob.find(@req.params['id'])
[200, {'Content-type' => 'text/html'}, [haml(:view)]]
when /retry/
@archived_job = Steve::ArchivedJob.find(@req.params['id'])
if @archived_job.retry!
[302, {'Location' => '/jobs/?status=retried'}]
else
[302, {'Location' => '/jobs/?status=retryfailed'}]
end
else
path = static_path(env['PATH_INFO'])
if File.exist?(path)
[200, {}, [File.read(path)]]
else
[404, {'Content-type' => 'text/plain'}, ["Not found"]]
end
end
end
|