Enhance Inkbunny job processing and update post handling

- Updated Rakefile to enqueue periodic jobs for Inkbunny latest posts, improving background processing.
- Added a check in UpdatePostsJob to handle cases with empty post IDs, preventing unnecessary processing.
- Enhanced IndexedPost model to support posting dates for Inkbunny posts.
- Refined view for displaying indexed posts, improving the presentation of posting dates and user experience.
This commit is contained in:
Dylan Knutson
2024-12-30 21:57:32 +00:00
parent c7e7bceb74
commit e781ed8f43
4 changed files with 23 additions and 11 deletions

View File

@@ -42,12 +42,19 @@ task periodic_tasks: %i[environment set_logger_stdout] do
Rake::Task["fa:browse_page_job"].execute
Rake::Task["fa:home_page_job"].execute
Rake::Task["e621:posts_index_job"].execute
Domain::Inkbunny::Job::UpdatePostsJob.set(
puts "enqueue periodic jobs"
sleep 1.minute
end
end
Thread.new do
loop do
puts "enqueue inkbunny latest posts"
Domain::Inkbunny::Job::LatestPostsJob.set(
queue: "inkbunny",
priority: -20,
).perform_later({})
puts "enqueue periodic jobs"
sleep 1.minute
sleep 2.minutes
end
end

View File

@@ -3,6 +3,12 @@ module Domain::Inkbunny::Job
def perform(args)
@caused_by_entry = args[:caused_by_entry]
@ib_post_ids = args[:ib_post_ids]
if @ib_post_ids.empty?
logger.info "empty ib_post_ids"
return
end
@ib_posts =
Domain::Inkbunny::Post
.where(ib_post_id: @ib_post_ids)

View File

@@ -51,6 +51,8 @@ class IndexedPost < ReduxApplicationRecord
postable&.posted_at
when "Domain::E621::Post"
postable&.posted_at
when "Domain::Inkbunny::Post"
postable&.posted_at
else
raise("Unsupported postable type: #{postable_type}")
end

View File

@@ -26,15 +26,12 @@
<h2 class="p-4 text-center text-lg">
<%= link_to post.title, show_path(post), class: "sky-link" %>
</h2>
<div class="px-4 pb-4 text-sm text-slate-600">
<div class="flex items-start justify-between">
<% if post.created_at %>
Posted <%= post.created_at.strftime("%Y-%m-%d") %>
<div class="text-slate-500">
(<%= time_ago_in_words(post.created_at) %> ago)
</div>
<div class="px-4 pb-4 text-sm text-slate-500">
<div class="flex justify-end">
<% if post.posted_at %>
Posted <%= time_ago_in_words(post.posted_at) %> ago
<% else %>
Posted date unknown
Post date unknown
<% end %>
</div>
</div>