mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
Dedupe before taking screenshots
This commit is contained in:
parent
b55584997f
commit
b2377051dc
1 changed files with 21 additions and 0 deletions
|
@ -12,6 +12,27 @@ class ScreenshotWorker
|
||||||
sidekiq_options queue: :screenshots, retry: 3, backtrace: true
|
sidekiq_options queue: :screenshots, retry: 3, backtrace: true
|
||||||
|
|
||||||
def perform(username, path)
|
def perform(username, path)
|
||||||
|
|
||||||
|
queue = Sidekiq::Queue.new self.class.sidekiq_options_hash['queue']
|
||||||
|
logger.info "JOB ID: #{jid} #{username} #{path}"
|
||||||
|
queue.each do |job|
|
||||||
|
if job.args == [username, path] && job.jid != jid
|
||||||
|
logger.info "DELETING #{job.jid} for #{username} #{path}"
|
||||||
|
job.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scheduled_jobs = Sidekiq::ScheduledSet.new.select do |scheduled_job|
|
||||||
|
scheduled_job.klass == 'ScreenshotWorker' &&
|
||||||
|
scheduled_job.args[0] == username &&
|
||||||
|
scheduled_job.args[1] == path
|
||||||
|
end
|
||||||
|
|
||||||
|
scheduled_jobs.each do |scheduled_job|
|
||||||
|
logger.info "DELETING scheduled job #{scheduled_job.jid} for #{username} #{path}"
|
||||||
|
scheduled_job.delete
|
||||||
|
end
|
||||||
|
|
||||||
path = "/#{path}" unless path[0] == '/'
|
path = "/#{path}" unless path[0] == '/'
|
||||||
|
|
||||||
uri = Addressable::URI.parse $config['screenshots_url']
|
uri = Addressable::URI.parse $config['screenshots_url']
|
||||||
|
|
Loading…
Add table
Reference in a new issue