script for fixing e621 posts
This commit is contained in:
25
Rakefile
25
Rakefile
@@ -234,12 +234,18 @@ end
|
||||
|
||||
task fix_e621_post_files: :environment do
|
||||
query = Domain::Post::E621Post.where(state: "ok").where.missing(:files)
|
||||
limit = ENV["limit"]&.to_i
|
||||
puts "query: #{query.to_sql}"
|
||||
|
||||
query.find_each(batch_size: 1) do |post|
|
||||
puts "post: #{post.id} / #{post.e621_id}"
|
||||
Domain::E621::Job::ScanPostJob.perform_now(post: post)
|
||||
break
|
||||
query.find_each(batch_size: 10) do |post|
|
||||
Domain::E621::Task::FixE621PostMissingFiles.new.run(post)
|
||||
if limit
|
||||
limit -= 1
|
||||
if limit.zero?
|
||||
puts "limit reached"
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -256,12 +262,7 @@ task perform_good_jobs: :environment do
|
||||
if job_id
|
||||
GoodJob::Job.where(id: job_id)
|
||||
else
|
||||
GoodJob::Job.where(
|
||||
job_class: job_class,
|
||||
finished_at: nil,
|
||||
error: nil,
|
||||
performed_at: nil,
|
||||
)
|
||||
GoodJob::Job.queued.where(job_class: job_class).order(created_at: :asc)
|
||||
end
|
||||
|
||||
relation.find_each(batch_size: 1) do |job|
|
||||
@@ -279,7 +280,6 @@ task perform_good_jobs: :environment do
|
||||
job_instance.deserialize(job.serialized_params)
|
||||
|
||||
puts "Running job #{job.id} (#{job.job_class})"
|
||||
puts "Arguments: #{deserialized_args.inspect}"
|
||||
|
||||
# Create execution record
|
||||
execution =
|
||||
@@ -333,6 +333,9 @@ task perform_good_jobs: :environment do
|
||||
)
|
||||
raise e
|
||||
ensure
|
||||
job.update!(
|
||||
executions_count: GoodJob::Execution.where(active_job_id: job.id).count,
|
||||
)
|
||||
# Restore original concurrency config
|
||||
job_class.good_job_concurrency_config = old_config
|
||||
GoodJob::CurrentThread.job = nil
|
||||
|
||||
Reference in New Issue
Block a user