Permalink
Browse files

failed jobs can be deleted and retried

  • Loading branch information...
1 parent a2e7203 commit b7ff451f1685e29fb91f19d7d59e4f6f469568b7 @akshayrawat committed Jul 1, 2012
@@ -35,3 +35,7 @@ code.block {
float: right;
margin: 0 2px;
}
+
+form.form-inline {
+ display: inline;
+}
@@ -31,7 +31,19 @@ def dj_counts
def settings
respond_with DjReport.settings
end
-
+
+ def retry
+ dj = Delayed::Job.find(params[:id])
+ dj.update_attribute :failed_at, nil if dj
+ redirect_to root_url, notice: "The job was been queued for a re-run" and return
+ end
+
+ def destroy
+ dj = Delayed::Job.find(params[:id])
+ dj.destroy if dj
+ redirect_to root_url, notice: "The job was deleted" and return
+ end
+
protected
def authenticate
@@ -18,7 +18,8 @@ def as_json(options={})
last_error: delayed_job.last_error,
failed_at: l_datetime(delayed_job.failed_at),
run_at: l_datetime(delayed_job.run_at),
- created_at: l_datetime(delayed_job.created_at)
+ created_at: l_datetime(delayed_job.created_at),
+ failed: delayed_job.failed_at.present?
}
end
@@ -30,11 +30,12 @@
%th
Last Error
%th.date
- Failed at
- %th.date
Run at
%th.date
Created at
+ %th.date
+ Failed at
+
%tbody
{{#.}}
%tr
@@ -50,11 +51,21 @@
%td
<a href="#last_error_template" data-content="{{last_error}}" rel='modal' title='Last Error'> {{last_error_summary}} </a>
%td.date
- {{failed_at}}
- %td.date
{{run_at}}
%td.date
{{created_at}}
+ %td.date
+ {{#failed}}
+ {{failed_at}}
+
+ = form_tag '/dj_mon/dj_reports/{{id}}/retry', method: :post, class: 'form-inline' do
+ = submit_tag 'Retry', class: 'btn btn-info btn-mini'
+
+ = form_tag '/dj_mon/dj_reports/{{id}}', method: :delete, class: 'form-inline' do
+ = submit_tag 'Delete', class: 'btn btn-danger btn-mini'
+
+ {{/failed}}
+
{{/.}}
%script#last_error_template{ :type=> "text/x-handlebars-template" }
@@ -16,6 +16,11 @@
.pull-right
#dj-counts-view
+
+ .container
+ - if flash[:notice]
+ .alert.alert-success
+ = flash[:notice]
.container
= yield
View
@@ -1,6 +1,6 @@
DjMon::Engine.routes.draw do
- resources :dj_reports, :only=> [ :index ] do
+ resources :dj_reports do
collection do
get :all
get :failed
@@ -9,6 +9,9 @@
get :dj_counts
get :settings
end
+ member do
+ post :retry
+ end
end
root :to => 'dj_reports#index'

0 comments on commit b7ff451

Please sign in to comment.