File tree 1 file changed +17
-9
lines changed
1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -15,18 +15,26 @@ def prepare_next_batch(batch_size)
15
15
16
16
private
17
17
def prepare_batch ( batch )
18
- prepared_at = Time . current
18
+ if batch . empty? then [ ]
19
+ else
20
+ promote_batch_to_ready ( batch )
21
+ end
22
+ end
19
23
20
- rows = batch . map do |scheduled_execution |
21
- scheduled_execution . ready_attributes . merge ( created_at : prepared_at )
24
+ def promote_batch_to_ready ( batch )
25
+ rows = ready_rows_from_batch ( batch )
26
+
27
+ SolidQueue ::ReadyExecution . insert_all ( rows )
28
+ SolidQueue ::ReadyExecution . where ( job_id : batch . map ( &:job_id ) ) . pluck ( :job_id ) . tap do |enqueued_job_ids |
29
+ where ( job_id : enqueued_job_ids ) . delete_all
22
30
end
31
+ end
23
32
24
- if rows . empty? then [ ]
25
- else
26
- SolidQueue ::ReadyExecution . insert_all ( rows )
27
- SolidQueue ::ReadyExecution . where ( job_id : batch . map ( &:job_id ) ) . pluck ( :job_id ) . tap do |enqueued_job_ids |
28
- where ( job_id : enqueued_job_ids ) . delete_all
29
- end
33
+ def ready_rows_from_batch ( batch )
34
+ prepared_at = Time . current
35
+
36
+ batch . map do |scheduled_execution |
37
+ scheduled_execution . ready_attributes . merge ( created_at : prepared_at )
30
38
end
31
39
end
32
40
end
You can’t perform that action at this time.
0 commit comments