Add job to clean dead links

This commit is contained in:
2023-05-08 21:57:32 +10:00
parent 96c23eafa6
commit ebdf051b82
9 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
require "httparty"
require "que"
module Adamantium
module Jobs
class RemoveDeadBookmarks < Que::Job
def run
bookmark_repo = Admin::Container["repos.bookmark_repo"]
bookmarks = bookmark_repo.list
bookmarks.each do |bookmark|
code = HTTParty.get(bookmark.url, follow_redirects: false).code
if code >= 400
bookmark_repo.archive(id: bookmark.id)
end
end
end
end
end
end