mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
remove redundant archive requests from queue
This commit is contained in:
parent
3023c8badd
commit
864903aa1f
1 changed files with 13 additions and 2 deletions
|
@ -1,8 +1,19 @@
|
|||
require 'sidekiq/api'
|
||||
|
||||
class ArchiveWorker
|
||||
include Sidekiq::Worker
|
||||
sidekiq_options queue: :archive, retry: 10, backtrace: true
|
||||
sidekiq_options queue: :archive, retry: 2, backtrace: true
|
||||
|
||||
def perform(site_id)
|
||||
Site[site_id].archive!
|
||||
site = Site[site_id]
|
||||
return if site.nil? || site.is_banned?
|
||||
|
||||
queue = Sidekiq::Queue.new self.class.sidekiq_options_hash['queue']
|
||||
|
||||
queue.each do |job|
|
||||
job.delete if job.args == [site_id] && job.jid != jid
|
||||
end
|
||||
|
||||
site.archive!
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue