tanga_que_extensions 0.0.21 → 0.0.22

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: d3904264261280fda0d1d7ce6416adcfc2caa065
4
- data.tar.gz: 0d685dcd94fe5f2949a7ef7d13f3bfc2460a0661
3
+ metadata.gz: bf1cafc0e3aca49b8e02bf055351a71c7a0a2ce6
4
+ data.tar.gz: 2e7d21483460f8954618ff9ad2735f58aa39f40c
5
5
  SHA512:
6
- metadata.gz: 520aaaba2a036bb83ef04b1a325a493072953ef56761c4b67ce1753a35071f09926057b3d76a3cf6c0da408bde00b5307fa889378e78840b8f9991f04466c191
7
- data.tar.gz: 870f9916cf591e5bc33e2d0e054b7c9637bd51a5977dd3b8ce9cef89d45465bc85528443ad73d1a10d7c930d070246ec6d660d9aed4ed09f9c98afc2b598bded
6
+ metadata.gz: 29c5baddb1020bdb3e9c5a9219dcc20ba05591a8d4a64f3f891eff7267590f725e3f939df57e80c76df707792d86569cd0e0903fe35b2000b2762f0da5a4baaa
7
+ data.tar.gz: 120b45d9f7b353b5348700e9c067a6750bbb687f98efd87d90daed0ba5e03be374b32013d10277be28a837899959fa773b7864816448a2a429e98842cf37d49b
data/lib/que_job.rb CHANGED
@@ -1,3 +1,8 @@
1
1
  class QueJob < ActiveRecord::Base
2
2
  self.primary_key = :job_id
3
+
4
+ def run
5
+ job_class.constantize.new(attributes.symbolize_keys)._run
6
+ destroy
7
+ end
3
8
  end
@@ -1,3 +1,9 @@
1
1
  class QueJobStatus < ActiveRecord::Base
2
2
  self.table_name = :que_job_status
3
+
4
+ def self.raw_job_data(job_id)
5
+ query = ['SELECT status, job_data from que_job_status where job_id = ?', job_id]
6
+ sanitized = sanitize_sql_array(query)
7
+ connection.execute(sanitized).first
8
+ end
3
9
  end
@@ -10,7 +10,7 @@ module Que::RecordJobStatus
10
10
  end
11
11
 
12
12
  def run(args={})
13
- @job_id = self.attrs['job_id']
13
+ @job_id = self.attrs.symbolize_keys[:job_id]
14
14
  record_job_started
15
15
  super if defined?(super)
16
16
  record_job_finished
data/test/test.rb CHANGED
@@ -5,13 +5,14 @@ require 'logger'
5
5
  require 'active_record'
6
6
  require_relative '../lib/tanga_que_extensions'
7
7
 
8
- ActiveRecord::Base.establish_connection 'postgres://localhost/tanga_dev'
8
+ ActiveRecord::Base.establish_connection 'postgres://localhost/channel_advisor_dev'
9
9
  Que.connection = ActiveRecord
10
10
 
11
- ActiveRecord::Base.logger = Logger.new($stdout)
11
+ QueJob.delete_all
12
+ QueJobStatus.delete_all
12
13
 
13
- #p QueJobStatus.first
14
- #p QueJob.first
14
+ # ActiveRecord::Base.logger = Logger.new($stdout)
15
+ # Que.logger = Logger.new(STDOUT)
15
16
 
16
17
  class J < Que::Job
17
18
  prepend Que::RecordJobStatus
@@ -39,17 +40,18 @@ class J < Que::Job
39
40
  end
40
41
  end
41
42
 
42
- Que.logger = Logger.new(STDOUT)
43
- Que.mode = :async
43
+
44
+ # Running job manually and getting status
45
+ job_id = J.enqueue({foo: 4, joe: 'args'}).attrs['job_id']
46
+ QueJob.find(job_id).run
47
+ puts QueJobStatus.raw_job_data(job_id)
48
+
49
+ Que.mode = :async
44
50
 
45
51
  loop do
46
52
  J.enqueue({foo: 1, joe: 'args'})
47
53
  J.enqueue({foo: 1, joe: 'args'})
48
- #J.enqueue({foo: 1, joe: 'args'})
49
- #J.enqueue({foo: 1, joe: 'args'})
50
- #J.enqueue({foo: 1, joe: 'args'})
51
- #J.enqueue({foo: 1, joe: 'args'})
54
+
52
55
  sleep 1
53
56
  end
54
57
 
55
- gets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanga_que_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Van Dyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: que