Skip to content

Commit

Permalink
Give me control over deleting the delayed_jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
aprilrieger committed Sep 28, 2023
1 parent 6126ad8 commit c5e0e9d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ def run_import
def logs
send_file(Rails.root.join('log/indexing.log'))
end

def destroy_all_delayed_jobs
Delayed::Job.destroy_all
redirect_to root_path, notice: 'All Delayed::Jobs have been destroyed.'
end
end
2 changes: 1 addition & 1 deletion app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% end %>
<%= link_to "Background Jobs", delayed_job_web_path, class: "btn btn-lg btn-primary" %>
<%= link_to "Download Logs", admin_logs_path, class: "btn btn-lg btn-primary" %>

<%= button_to "Destroy All Delayed Jobs", destroy_all_delayed_jobs_path, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-lg btn-danger' %>
<div class="g-mt-40 g-mb-40">
<%= link_to t('blacklight.header_links.logout'), destroy_user_session_path %>
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/views/delayed_jobs/destroy_all.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- app/views/delayed_jobs/destroy_all.html.erb -->
<h1>Destroy All Delayed Jobs</h1>
<p>Are you sure you want to destroy all Delayed Jobs?</p>
<%= button_to 'Destroy All', destroy_all_delayed_jobs_path, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

post 'admin/run_import', to: 'admin#run_import', as: 'run_import'

delete 'destroy_all_delayed_jobs', to: 'admin#destroy_all_delayed_jobs'

mount Blacklight::Engine => '/'
mount BlacklightDynamicSitemap::Engine => '/'

Expand Down

0 comments on commit c5e0e9d

Please sign in to comment.