more progress on visual search

This commit is contained in:
Dylan Knutson
2025-03-04 14:56:42 +00:00
parent f845d06267
commit 0d32ef2802
11 changed files with 563 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ namespace :fingerprint do
end
end
task for_ids: :environment do
task for_posts: :environment do
ids = ENV["IDS"].split(",")
pb = ProgressBar.create(total: ids.size)
ids.each do |id|
@@ -19,4 +19,30 @@ namespace :fingerprint do
pb.progress = [pb.progress + 1, pb.total].min
end
end
task for_users: :environment do
ids = ENV["IDS"].split(",")
ids.each do |id|
user = DomainController.find_model_from_param(Domain::User, id)
puts "migrating #{id}: #{user.posts.count} posts"
pb =
ProgressBar.create(
total: user.posts.count,
format: "%t: %c/%C %B %p%% %a %e",
)
user
.posts
.includes(:files)
.find_in_batches(batch_size: 10) do |batch|
ReduxApplicationRecord.transaction do
batch.each do |post|
post.files.each do |file|
file.create_fingerprint unless file.fingerprint
end
pb.progress = [pb.progress + 1, pb.total].min
end
end
end
end
end
end