better job dedup key computation

This commit is contained in:
Dylan Knutson
2025-06-26 17:59:32 +00:00
parent e3b2463cbe
commit 3a06181db8
9 changed files with 255 additions and 50 deletions

View File

@@ -293,6 +293,8 @@ task run_fa_user_avatar_jobs: :environment do
end
task create_post_file_fingerprints: %i[environment set_logger_stdout] do
PB_FORMAT = "%B %c/%C (%r/sec) %J%% %a %E"
def migrate_posts_for_user(user)
puts "migrating posts for #{user.to_param}"
posts = user.posts.includes(files: %i[blob thumbnails bit_fingerprints])
@@ -302,7 +304,7 @@ task create_post_file_fingerprints: %i[environment set_logger_stdout] do
total: posts.count,
progress_mark: " ",
remainder_mark: " ",
format: "%B %c/%C (%r/sec) %J%% %a %E",
format: PB_FORMAT,
)
posts.find_in_batches(batch_size: 64) do |batch|
@@ -341,7 +343,7 @@ task create_post_file_fingerprints: %i[environment set_logger_stdout] do
total:,
progress_mark: " ",
remainder_mark: " ",
format: "%B %c/%C (%r/sec) %J%% %a %E",
format: PB_FORMAT,
)
i = 0
Domain::PostFile
@@ -354,7 +356,11 @@ task create_post_file_fingerprints: %i[environment set_logger_stdout] do
) do |post_file|
i += 1
if i % 100 == 0
puts "migrating #{post_file.id} / #{post_file.post.title_for_view}"
post_desc =
"#{post_file.post.creator&.to_param&.rjust(20)} / #{post_file.post&.to_param}".ljust(
40,
)
puts "post_file = #{post_file.id} :: #{post_desc} - #{post_file.post.title_for_view}"
end
migrate_post_file(post_file)
pb.progress = [pb.progress + 1, pb.total].min
@@ -367,7 +373,7 @@ task create_post_file_fingerprints: %i[environment set_logger_stdout] do
total:,
progress_mark: " ",
remainder_mark: " ",
format: "%B %c/%C (%r/sec) %J%% %a %E",
format: PB_FORMAT,
)
Domain::Post.find_each(order: :desc) do |post|
migrate_post(post) unless post.is_a?(Domain::Post::InkbunnyPost)