Skip to content

Commit b5a6cf9

Browse files
committed
Add reverse processor for long queues
1 parent d115e93 commit b5a6cf9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require 'submission_processor'
4+
5+
class SubmissionLongQueueProcessorTask
6+
def initialize
7+
@processor = SubmissionProcessor.new
8+
end
9+
10+
def run
11+
queue = Submission.to_be_reprocessed.where(processing_priority: 0).order(:created_at).reverse_order
12+
return if queue.length <= 10
13+
Rails.logger.info "#{queue.length} high priority submissions in queue, trying to process some of them in reverse order..."
14+
queue.limit(RemoteSandbox.total_capacity).each do |sub|
15+
Rails.logger.info "Processing submission #{sub} in from the front of the queue since submission queue is so long..."
16+
@processor.process_submission(sub)
17+
Rails.logger.info "Processing submission #{sub} done"
18+
end
19+
end
20+
21+
def wait_delay
22+
1
23+
end
24+
end

0 commit comments

Comments
 (0)