Add job to clean dead links
This commit is contained in:
22
slices/admin/actions/bookmarks/clean.rb
Normal file
22
slices/admin/actions/bookmarks/clean.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require "que"
|
||||
|
||||
module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Clean < Action
|
||||
|
||||
def handle(req, res)
|
||||
Que.connection = Adamantium::Container["persistence.db"]
|
||||
|
||||
res.status = 200
|
||||
if Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::RemoveDeadBookmarks.name }
|
||||
res.body = "Job already queued"
|
||||
else
|
||||
Adamantium::Jobs::RemoveDeadBookmarks.enqueue
|
||||
res.body = "#{Que.job_stats.count} job queued"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -7,6 +7,13 @@ module Admin
|
||||
.to_a
|
||||
end
|
||||
|
||||
def list_published
|
||||
posts
|
||||
.published
|
||||
.where(post_type: "bookmark")
|
||||
.to_a
|
||||
end
|
||||
|
||||
def fetch(id:)
|
||||
posts.where(id: id).one
|
||||
end
|
||||
|
@@ -2,6 +2,9 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
|
||||
h1 Admin // Bookmarks
|
||||
|
||||
div class="max-w-prose mx-auto"
|
||||
|
||||
button class="rounded bg-blue-100 hover:bg-blue-200 text-blue-600 px-2 hover:cursor-pointer" hx-post="/admin/bookmarks/clean" Check for dead links
|
||||
|
||||
table class="prose dark:prose-invert table-auto prose-a:text-blue-600 prose-a:no-underline"
|
||||
thead
|
||||
th Details
|
||||
|
Reference in New Issue
Block a user