statesman 1.2.4 → 1.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: 8247dd4b145c4c16a848f6cba121782199a05f43
4
- data.tar.gz: 2f4b476e0b585f432f06985d759357d84f1ac1d1
3
+ metadata.gz: 587d4c564a33a0b209ac791260a29d338f2ab19d
4
+ data.tar.gz: 805d0d04ee16c728c602ff7cf3ac3b0ad45f0594
5
5
  SHA512:
6
- metadata.gz: 52b5b0d12f0b0741874afa857633c91e0eeba7c79678cb8f4da9d474b2227f7ca870cfa5ead883ad780a503a77028de7fa830e890e7d5611683245da0f00500d
7
- data.tar.gz: df47a34f64bcea46519b56c450ceb0cec66233316fb03ff515578074babb6ecdcb98136ff357e8c7fb7fbf12359187c320f1101abd7aab97e1dab936ebfab2d3
6
+ metadata.gz: 6d6418d12ffcd11a87b34d5cf150ef79de2c98ad7d3eb9b5e0ff8985d8991a82ba23820344c99b52c6f6b3763b335a53935e797b88ba5d9733d20183539fc358
7
+ data.tar.gz: 257f73f7c2f9051d943d1c135ff3f96761a14bc4de5c31e6a5f1c921ca96d14432b711ac3cb1213b843531384910b347986c77fcdc1fc5ed79de68b1f9420c8e
data/.travis.yml CHANGED
@@ -22,6 +22,6 @@ env:
22
22
  - "RAILS_VERSION=3.2.21"
23
23
  - "RAILS_VERSION=4.0.13"
24
24
  - "RAILS_VERSION=4.1.10"
25
- - "RAILS_VERSION=4.2.1"
26
- - "RAILS_VERSION=4.2.1 DATABASE_URL=mysql2://root@localhost/statesman_test"
27
- - "RAILS_VERSION=4.2.1 DATABASE_URL=postgres://postgres@localhost/statesman_test"
25
+ - "RAILS_VERSION=4.2.2"
26
+ - "RAILS_VERSION=4.2.2 DATABASE_URL=mysql2://root@localhost/statesman_test"
27
+ - "RAILS_VERSION=4.2.2 DATABASE_URL=postgres://postgres@localhost/statesman_test"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.2.5 17 June 2015
2
+
3
+ - Make `backfill_most_recent` rake task db-agnostic (patch by [@timothyp](https://github.com/timothyp))
4
+
1
5
  ## v1.2.4 16 June 2015
2
6
 
3
7
  - Clarify error messages when misusing `Statesman::Adapters::ActiveRecordTransition` (patch by [@isaacseymour](https://github.com/isaacseymour))
@@ -1,3 +1,3 @@
1
1
  module Statesman
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -25,24 +25,26 @@ namespace :statesman do
25
25
  end
26
26
 
27
27
  # Set current transition's most_recent to TRUE
28
- ActiveRecord::Base.connection.execute %{
29
- UPDATE #{transition_class.table_name}
30
- SET most_recent = true
31
- FROM
32
- (
33
- SELECT initial_t.id, subsequent_t.created_at
34
- FROM #{transition_class.table_name} initial_t
35
- LEFT JOIN #{transition_class.table_name} subsequent_t ON
36
- (
37
- initial_t.#{parent_fk} = subsequent_t.#{parent_fk}
38
- AND initial_t.sort_key < subsequent_t.sort_key
39
- )
40
- WHERE initial_t.#{parent_fk}
41
- IN (#{models.map { |p| "'#{p.id}'" }.join(',')})
42
- AND subsequent_t.id IS NULL
43
- ) x
44
- WHERE #{transition_class.table_name}.id = x.id
45
- }
28
+ initial_t = transition_class.arel_table
29
+ subsequent_t = initial_t.alias
30
+
31
+ later_row_for_same_parent = initial_t[parent_fk].
32
+ eq(subsequent_t[parent_fk]).
33
+ and(initial_t[:sort_key].
34
+ lt(subsequent_t[:sort_key]))
35
+
36
+ no_later_row = subsequent_t[:id].eq(nil)
37
+ in_current_parent_batch = initial_t[parent_fk].in(models.map(&:id))
38
+
39
+ latest_ids_query = initial_t.join(subsequent_t, Arel::Nodes::OuterJoin).
40
+ on(later_row_for_same_parent).
41
+ where(no_later_row.and(in_current_parent_batch)).
42
+ project(initial_t[:id]).to_sql
43
+
44
+ latest_ids = transition_class.find_by_sql(latest_ids_query).
45
+ to_a.collect(&:id)
46
+
47
+ transition_class.where(id: latest_ids).update_all(most_recent: true)
46
48
  end
47
49
 
48
50
  done_models += batch_size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
@@ -9,202 +9,202 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-16 00:00:00.000000000 Z
12
+ date: 2015-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.1'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.1'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec-rails
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.1'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.1'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-its
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.1'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.1'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: guard-rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: '4.3'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ~>
96
96
  - !ruby/object:Gem::Version
97
97
  version: '4.3'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ~>
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.30.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ~>
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.30.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: guard-rubocop
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "~>"
116
+ - - ~>
117
117
  - !ruby/object:Gem::Version
118
118
  version: '1.2'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "~>"
123
+ - - ~>
124
124
  - !ruby/object:Gem::Version
125
125
  version: '1.2'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: sqlite3
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: '1.3'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - ~>
138
138
  - !ruby/object:Gem::Version
139
139
  version: '1.3'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: mongoid
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ">="
144
+ - - '>='
145
145
  - !ruby/object:Gem::Version
146
146
  version: '3.1'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - '>='
152
152
  - !ruby/object:Gem::Version
153
153
  version: '3.1'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: rails
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '3.2'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - '>='
166
166
  - !ruby/object:Gem::Version
167
167
  version: '3.2'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: pg
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - "~>"
172
+ - - ~>
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0.18'
175
175
  type: :development
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - "~>"
179
+ - - ~>
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0.18'
182
182
  - !ruby/object:Gem::Dependency
183
183
  name: mysql2
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - "~>"
186
+ - - ~>
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0.3'
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - "~>"
193
+ - - ~>
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0.3'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: ammeter
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - "~>"
200
+ - - ~>
201
201
  - !ruby/object:Gem::Version
202
202
  version: '1.1'
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - "~>"
207
+ - - ~>
208
208
  - !ruby/object:Gem::Version
209
209
  version: '1.1'
210
210
  description: A statesmanlike state machine library
@@ -214,9 +214,9 @@ executables: []
214
214
  extensions: []
215
215
  extra_rdoc_files: []
216
216
  files:
217
- - ".gitignore"
218
- - ".rubocop.yml"
219
- - ".travis.yml"
217
+ - .gitignore
218
+ - .rubocop.yml
219
+ - .travis.yml
220
220
  - CHANGELOG.md
221
221
  - CONTRIBUTING.md
222
222
  - Gemfile
@@ -288,17 +288,17 @@ require_paths:
288
288
  - lib
289
289
  required_ruby_version: !ruby/object:Gem::Requirement
290
290
  requirements:
291
- - - ">="
291
+ - - '>='
292
292
  - !ruby/object:Gem::Version
293
293
  version: '0'
294
294
  required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  requirements:
296
- - - ">="
296
+ - - '>='
297
297
  - !ruby/object:Gem::Version
298
298
  version: '0'
299
299
  requirements: []
300
300
  rubyforge_project:
301
- rubygems_version: 2.4.1
301
+ rubygems_version: 2.2.2
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: A statesmanlike state machine library
@@ -326,4 +326,3 @@ test_files:
326
326
  - spec/support/active_record.rb
327
327
  - spec/support/generators_shared_examples.rb
328
328
  - spec/support/mongoid.rb
329
- has_rdoc: