sidejobs 5.1.0 → 5.1.1

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: 576d715438f5bf28ed6f478ba5d81a47bf737907
4
- data.tar.gz: dccae5be6356b8aac334dc6a77a4f46fd418d4e1
3
+ metadata.gz: '0911dac77f937d3227914732dd6120de78360b0a'
4
+ data.tar.gz: 4f65f14fd0c5bc20d02953f165afb4548c47d187
5
5
  SHA512:
6
- metadata.gz: 6c1be39cf38b2c6bc18eaadcc211ae732e3e8c1c4c710c551ca8514d7ae6162a9868bda36a49875d06bcd0a3d5a8bfb12c46faa9a677d34a9c103cab589390ed
7
- data.tar.gz: 715e43fbf5241459c37801b5a4d43a8c1b4ac1f235da2451d512eb78482a573dcb0f51f62c2547bc62805565cf588feebf815aa9040d76c389a1196cd7ba9fd6
6
+ metadata.gz: ba869b6c3c50497e2e6e1901dce7447383c578680a029107eb59e7d1c3b078016c04ea13aeb1d30712c8ae82b167efc50117705b11accab5b8929f3b63a14e98
7
+ data.tar.gz: 4345486f1017beea0c53f1323ea5106bfb09295379072c1f42c9b9c64707d84335690af91c9676f82b896650cc9909505421c3338627e809d49e1c4b6669f2db
@@ -1,21 +1,21 @@
1
- class CreateSidejobs < ActiveRecord::Migration
1
+ class CreateSidejobs < ActiveRecord::Migration[5.1]
2
2
  def change
3
3
  create_table :sidejobs do |t|
4
4
  t.jsonb :data
5
5
  t.string :queue
6
- t.string :status, default: 'pending'
6
+ t.string :state, default: 'pending'
7
7
  t.integer :priority, default: 0
8
8
  t.integer :attempts, default: 0
9
9
  t.text :error
10
- t.datetime :failed_at
11
- t.datetime :completed_at
12
10
  t.datetime :processed_at
13
11
  t.datetime :scheduled_at
14
12
 
15
13
  t.timestamps null: false
16
14
  end
17
15
 
18
- add_index :sidejobs, %i(status scheduled_at attempts)
16
+ add_index :sidejobs, :state
17
+ add_index :sidejobs, :scheduled_at
18
+ add_index :sidejobs, :attempts
19
19
  add_index :sidejobs, :priority
20
20
  end
21
21
  end
@@ -1,20 +1,19 @@
1
1
  module Sidejobs
2
2
  class Job < ActiveRecord::Base
3
3
 
4
- STATUS = %w(pending processing failing complete)
4
+ STATES = %w(pending processing failing complete)
5
5
 
6
- STATUS.each do |name|
7
- scope name, -> { where(status: name) }
6
+ STATES.each do |name|
7
+ scope name, -> { where(state: name) }
8
8
  define_method "#{name}?" do
9
- status == name
9
+ state == name
10
10
  end
11
11
  end
12
12
 
13
- validates_presence_of :queue, :data, :status
14
- validates_presence_of :error, :failed_at, if: :failing?
15
- validates_presence_of :completed_at, if: :complete?
13
+ validates_presence_of :queue, :data, :state
14
+ validates_presence_of :error, if: :failing?
16
15
  validates_presence_of :processed_at, if: :processing?
17
- validates_inclusion_of :status, within: STATUS
16
+ validates_inclusion_of :state, within: STATES
18
17
  validates_numericality_of :priority, :attempts, only_integer: true
19
18
 
20
19
  def self.table_name
@@ -4,12 +4,12 @@ module Sidejobs
4
4
 
5
5
  def process
6
6
  Sidejobs.queue.fetch.each do |job|
7
- job.update status: 'processing', processed_at: Time.now, attempts: job.attempts+1
7
+ job.update state: 'processing', processed_at: Time.zone.now, attempts: job.attempts+1
8
8
  begin
9
9
  ActiveJob::Base.execute job.data
10
- job.update status: 'complete', completed_at: Time.now
10
+ job.update state: 'complete'
11
11
  rescue => exception
12
- job.update status: 'failing', failed_at: Time.now, error: exception.message
12
+ job.update state: 'failing', error: exception.message
13
13
  end
14
14
  end
15
15
  end
@@ -11,7 +11,7 @@ module Sidejobs
11
11
  end
12
12
 
13
13
  def fetch
14
- Job.where(status: %w(pending failing)).where(
14
+ Job.where(state: %w(pending failing)).where(
15
15
  'attempts < ?',
16
16
  Sidejobs.configuration.max_attempts
17
17
  ).where(
@@ -1,5 +1,5 @@
1
1
  module Sidejobs
2
2
 
3
- VERSION = '5.1.0'
3
+ VERSION = '5.1.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidejobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails