delay_henka 0.2.4 → 0.2.5

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: a9dc7cc926b1cce96ff3d2d7d5b2cbc17e05d92d
4
- data.tar.gz: 84415334ddc990bdd629f1e75a546ba6d5b770de
3
+ metadata.gz: 553f5923622e1bd283778df3469ef3842786e916
4
+ data.tar.gz: 88e2cc8dceca907f56c47b875db18cbd4c7854ee
5
5
  SHA512:
6
- metadata.gz: b6c3c885759872583eda50b5ae942f5c828b17fcd864363fc59466e519fe0385ff418cc2a9e38ccc629460e6262a6f991796ed49ca13ddfde38cdf27e1805a86
7
- data.tar.gz: b41d6278d9c2374b0a587406ea9bd4b3caef9acbe5bab1ddce2b9c6afdf4e7d4a4febea3df216e016e4842d479dcc26262f6d1d1bc6de49cfddae266581132d6
6
+ metadata.gz: 7f1ce8f03834e7eecce350b8eed1baefa212ae2aab2834b6df5bdcc34b46478edd7a0b81edaed075e422486630152190c76ac3dd70a7e6f1b10eb6cb28de7fbf
7
+ data.tar.gz: 742b11afdb114d5ac7cf06569312225870df8ef0b1d66981ad2ce7ec1a6adf38ced54092a66c75929b911d31d8ecafeecea8901fbe59e260e7e39d32e6f380cb
@@ -11,18 +11,19 @@ module DelayHenka
11
11
  belongs_to :changeable, polymorphic: true
12
12
 
13
13
  validates :submitted_by_id, :attribute_name, presence: true
14
+ validates :schedule_at, presence: true
14
15
  validates :state, inclusion: { in: STATES.values }
15
16
  after_initialize :set_initial_state, if: :new_record?
16
17
 
17
18
  scope :staged, -> { where(state: STATES[:STAGED]) }
18
19
 
19
- def self.schedule(record:, changes:, by_id:)
20
+ def self.schedule(record:, changes:, by_id:, schedule_at: Time.current)
20
21
  changes.each do |attribute, new_val|
21
22
  old_val = record.public_send(attribute)
22
23
  cleaned_new_val = cleanup_val(new_val)
23
24
  record.public_send("#{attribute}=", cleaned_new_val)
24
25
  next unless record.public_send("#{attribute}_changed?")
25
- create!(changeable: record, submitted_by_id: by_id, attribute_name: attribute, old_value: old_val, new_value: cleaned_new_val)
26
+ create!(changeable: record, submitted_by_id: by_id, attribute_name: attribute, old_value: old_val, new_value: cleaned_new_val, schedule_at: schedule_at)
26
27
  end
27
28
  end
28
29
 
@@ -5,6 +5,7 @@ module DelayHenka
5
5
 
6
6
  def perform
7
7
  ScheduledChange.staged
8
+ .where('schedule_at <= ?', Time.current)
8
9
  .includes(:changeable)
9
10
  .group_by{ |change| [change.changeable_type, change.changeable_id, change.attribute_name] }
10
11
  .values
@@ -0,0 +1,5 @@
1
+ class AddScheduleAt < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :delay_henka_scheduled_changes, :schedule_at, :datetime, null: false
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module DelayHenka
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delay_henka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ files:
104
104
  - app/workers/delay_henka/apply_changes_worker.rb
105
105
  - config/routes.rb
106
106
  - db/migrate/20181228205218_create_delay_henka_scheduled_changes.rb
107
+ - db/migrate/20190225140848_add_schedule_at.rb
107
108
  - lib/delay_henka.rb
108
109
  - lib/delay_henka/engine.rb
109
110
  - lib/delay_henka/version.rb