acts_as_ranked_list 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/acts_as_ranked_list/active_record/rank_column.rb +14 -2
- data/lib/acts_as_ranked_list/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c665111b3d1da9b578d19b1c49203ae597e49a06e09f274e92cb7cecca03687
|
4
|
+
data.tar.gz: d4d682b766b048afcc9af37fabcb99e37e683a2d0924e32a2d4a3941a6c29f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf228e285474e6ffdee7aeeb36c5a024ee897a640a8f9dbc486faf4e7b8fd431e2c11907137e1f15fec253e0ee4ec38e7b73cedf2883690b1482261032a9cd87
|
7
|
+
data.tar.gz: 922b5ad1fa695325e779a3a44db204b3457a84d0b5bcec539cb16c492c48abe3c82a92acf978984aa3d758846fc532fe1f9c829c41eed9fe4f764f6852414afa
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.4.0] - 2024-02-12
|
11
|
+
|
12
|
+
- Fixes sporadic bug on postgres with `pluck` higher items.
|
13
|
+
|
14
|
+
## [0.3.0] - 2024-02-11 [YANKED]
|
15
|
+
|
16
|
+
- Fixes individual items updating timestamps even when `touch_on_update` is false.
|
17
|
+
|
10
18
|
## [0.2.3] - 2023-12-31
|
11
19
|
|
12
20
|
- Updates gem dependencies.
|
@@ -198,7 +198,9 @@ module ActsAsRankedList #:nodoc:
|
|
198
198
|
|
199
199
|
define_method :set_rank_above do |item|
|
200
200
|
higher_items = get_higher_items(2, "DESC", item.current_rank, true, true)
|
201
|
-
|
201
|
+
# TODO: Why is higher_items and lower_items sometimes need to be converted to array.
|
202
|
+
# Is it related to if items are not found? Otherwise it returns an error
|
203
|
+
padded_array = pad_array(higher_items.to_a.pluck(rank_column), 0)
|
202
204
|
new_rank = padded_array.sum / 2
|
203
205
|
|
204
206
|
with_persistence do
|
@@ -223,7 +225,7 @@ module ActsAsRankedList #:nodoc:
|
|
223
225
|
# new_rank = ::ActiveRecord::Base.connection.execute(sql).to_a.first.values.first
|
224
226
|
|
225
227
|
lower_items = get_lower_items(2, "ASC", item.current_rank, true, true)
|
226
|
-
padded_array = pad_array(lower_items.pluck(rank_column))
|
228
|
+
padded_array = pad_array(lower_items.to_a.pluck(rank_column))
|
227
229
|
new_rank = padded_array.sum / 2
|
228
230
|
|
229
231
|
with_persistence do
|
@@ -312,7 +314,17 @@ module ActsAsRankedList #:nodoc:
|
|
312
314
|
define_method :with_persistence do |items = [self], &blk|
|
313
315
|
blk.call
|
314
316
|
|
317
|
+
item_record_timestamps = items.map do |i|
|
318
|
+
i.record_timestamps?
|
319
|
+
end
|
320
|
+
|
321
|
+
items.each { |i| i.record_timestamps = touch_on_update }
|
322
|
+
|
315
323
|
items.each(&:save!) unless skip_persistence?
|
324
|
+
|
325
|
+
items.each_with_index do |i, idx|
|
326
|
+
i.record_timestamps = item_record_timestamps[idx]
|
327
|
+
end
|
316
328
|
end
|
317
329
|
|
318
330
|
define_method :pad_array do |array, value = nil, size = 2|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_ranked_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Farbafe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|