tanga_que_extensions 0.0.26 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba5e294d93099e6a579f679d3911fef19c85ee03
4
- data.tar.gz: 73f13d6194b3c285871f59d412f12a6788d0fe9c
3
+ metadata.gz: f614ac8cdd834509af12ae7c9021e3211555340e
4
+ data.tar.gz: b2a20d5f534086c6581ddb0be634c0c983614fc1
5
5
  SHA512:
6
- metadata.gz: 4849f10a929cc2d420bcd78ed4bd16a8c4e61b610535ed34ae91114a19a627add31fa07facdcf0bb3f2a8d2638d7fc397bc998aa795e5fe9a8eaf3a9b36539e1
7
- data.tar.gz: 66f9ce127ccf75691a2edb5f30c873856db47fae19371543a6e3e79bef952ea134109225a0478d3b43fd902f472b77ee3c29f82546909ff8bf5dae55c4efc1c9
6
+ metadata.gz: 5a45896e61025aa10231b324a13117badfed2c4f71d3b23e7ead183fde937b3ffcc1ee3eab806b0a4d7b27040ed0c8898186561216153b9d5110eed708829f13
7
+ data.tar.gz: f45a72e77b829b8f8c4da950e3299bfbc41192d569440f47555b036d39b8f652874de4d96c02cdbf5bb1eff16a8dbfffac3d418d5cf6109a2e6bd4f8af6de4c5
@@ -3,10 +3,15 @@ module Jobs
3
3
  def run(options)
4
4
  unless QueJob.where(parent_job_id: options[:job_id]).count > 0
5
5
  QueJobStatus.where(job_id: options[:job_id]).update_all(finished_at: Time.now, status: 'finished')
6
+
7
+ if options[:on_finished_job_class].present?
8
+ options[:on_finished_job_class].constantize.enqueue(job_id: options[:job_id]);
9
+ end
10
+
6
11
  return
7
12
  end
8
13
 
9
- self.class.enqueue(options.merge(run_at: Time.current + 1.second))
14
+ self.class.enqueue(options.merge(run_at: Time.current + 5.second))
10
15
  end
11
16
  end
12
17
  end
@@ -1,6 +1,9 @@
1
1
  module Que::WaitForChildJobs
2
2
  def record_job_finished
3
3
  job_scope.update_all(status: 'waiting-for-child-jobs')
4
- Jobs::WatchChildJobs.enqueue(job_id: job_id)
4
+ Jobs::WatchChildJobs.enqueue(
5
+ job_id: job_id,
6
+ on_finished_job_class: (defined? on_finished_job_class) ? on_finished_job_class : nil
7
+ )
5
8
  end
6
9
  end
@@ -12,6 +12,14 @@ Que.connection = ActiveRecord
12
12
 
13
13
  ActiveRecord::Base.logger = Logger.new($stdout)
14
14
 
15
+ class OnFinish < Que::Job
16
+ prepend Que::RecordJobStatus
17
+
18
+ def run(args)
19
+ puts args.inspect
20
+ end
21
+ end
22
+
15
23
  class Child < Que::ChildJob
16
24
  prepend Que::RecordJobStatus
17
25
  prepend Que::RecordJobStatusToParentJob
@@ -31,6 +39,10 @@ class Parent < Que::Job
31
39
  Child.enqueue(i: i, parent_job_id: job_id)
32
40
  end
33
41
  end
42
+
43
+ def on_finished_job_class
44
+ OnFinish.to_s
45
+ end
34
46
  end
35
47
 
36
48
  QueJob.delete_all
@@ -40,3 +52,5 @@ Que.mode = :async
40
52
 
41
53
  Parent.enqueue
42
54
  gets
55
+ Que.mode = :none
56
+ binding.pry
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanga_que_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Van Dyk