diff --git a/lib/adamantium/jobs/remove_dead_bookmarks.rb b/lib/adamantium/jobs/archive_dead_bookmarks.rb similarity index 72% rename from lib/adamantium/jobs/remove_dead_bookmarks.rb rename to lib/adamantium/jobs/archive_dead_bookmarks.rb index 5e54705..41e3b76 100644 --- a/lib/adamantium/jobs/remove_dead_bookmarks.rb +++ b/lib/adamantium/jobs/archive_dead_bookmarks.rb @@ -3,7 +3,7 @@ require "que" module Adamantium module Jobs - class RemoveDeadBookmarks < Que::Job + class ArchiveDeadBookmarks < Que::Job def run bookmark_repo = Admin::Container["repos.bookmark_repo"] @@ -12,7 +12,7 @@ module Adamantium bookmarks.each do |bookmark| code = HTTParty.get(bookmark.url, follow_redirects: false).code if code >= 400 - bookmark_repo.archive(id: bookmark.id) + bookmark_repo.update(bookmark.id, {url: "https://web.archive.org/web/*/#{bookmark.url}"}) end end end diff --git a/slices/admin/actions/bookmarks/clean.rb b/slices/admin/actions/bookmarks/clean.rb index f2abf36..d5813cd 100644 --- a/slices/admin/actions/bookmarks/clean.rb +++ b/slices/admin/actions/bookmarks/clean.rb @@ -8,10 +8,10 @@ module Admin Que.connection = Adamantium::Container["persistence.db"] res.status = 200 - if Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::RemoveDeadBookmarks.name } + if Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::ArchiveDeadBookmarks.name } res.body = "Job already queued" else - Adamantium::Jobs::RemoveDeadBookmarks.enqueue + Adamantium::Jobs::ArchiveDeadBookmarks.enqueue res.body = "#{Que.job_stats.count} job queued" end end diff --git a/slices/admin/views/bookmarks/index.rb b/slices/admin/views/bookmarks/index.rb index d85351b..ff5883a 100644 --- a/slices/admin/views/bookmarks/index.rb +++ b/slices/admin/views/bookmarks/index.rb @@ -20,7 +20,7 @@ module Admin expose :running_jobs do Que.connection = Adamantium::Container["persistence.db"] - Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::RemoveDeadBookmarks.name } + Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::ArchiveDeadBookmarks.name } end end end