@@ -6,14 +6,12 @@ module Executable
6
6
extend ActiveSupport ::Concern
7
7
8
8
included do
9
- include Clearable , ConcurrencyControls
9
+ include Clearable , ConcurrencyControls , Schedulable
10
10
11
11
has_one :ready_execution , dependent : :destroy
12
12
has_one :claimed_execution , dependent : :destroy
13
13
has_one :failed_execution , dependent : :destroy
14
14
15
- has_one :scheduled_execution , dependent : :destroy
16
-
17
15
after_create :prepare_for_execution
18
16
19
17
scope :finished , -> { where . not ( finished_at : nil ) }
@@ -35,20 +33,11 @@ def dispatch_all(jobs)
35
33
successfully_dispatched ( jobs )
36
34
end
37
35
38
- def schedule_all ( jobs )
39
- schedule_all_at_once ( jobs )
40
- successfully_scheduled ( jobs )
41
- end
42
-
43
36
private
44
37
def dispatch_all_at_once ( jobs )
45
38
ReadyExecution . create_all_from_jobs jobs
46
39
end
47
40
48
- def schedule_all_at_once ( jobs )
49
- ScheduledExecution . create_all_from_jobs ( jobs )
50
- end
51
-
52
41
def dispatch_all_one_by_one ( jobs )
53
42
jobs . each ( &:dispatch )
54
43
end
@@ -64,13 +53,9 @@ def dispatched_and_ready(jobs)
64
53
def dispatched_and_blocked ( jobs )
65
54
where ( id : BlockedExecution . where ( job_id : jobs . map ( &:id ) ) . pluck ( :job_id ) )
66
55
end
67
-
68
- def successfully_scheduled ( jobs )
69
- where ( id : ScheduledExecution . where ( job_id : jobs . map ( &:id ) ) . pluck ( :job_id ) )
70
- end
71
56
end
72
57
73
- %w[ ready claimed failed scheduled ] . each do |status |
58
+ %w[ ready claimed failed ] . each do |status |
74
59
define_method ( "#{ status } ?" ) { public_send ( "#{ status } _execution" ) . present? }
75
60
end
76
61
@@ -117,10 +102,6 @@ def failed_with(exception)
117
102
end
118
103
119
104
private
120
- def schedule
121
- ScheduledExecution . create_or_find_by! ( job_id : id )
122
- end
123
-
124
105
def ready
125
106
ReadyExecution . create_or_find_by! ( job_id : id )
126
107
end
0 commit comments