weighted_list_rank 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d6af0dabc07041ac8d52dade9dcaf6788e68d1b8809e85e5dc57d9cf032b83c
4
- data.tar.gz: 913262cd828e18bc68bc69d4f62bc422b17c2711d82de7132f887d2732d65534
3
+ metadata.gz: 4056bebc06742afb336a7dd554e0147b782981a4cddb6b56a80239cccd9f6ae3
4
+ data.tar.gz: 3e1932ffba58a189db05a444cd9eb44581776119ac1566b3ea2f853c7657cb5f
5
5
  SHA512:
6
- metadata.gz: e3d0d1f24a242c249337c9dd2889d0468bb616fbead79ebabdda1d7bf3ad629c962e6b004d0b7051933d91fb1a8f5aa15602c70858a9ed7b20bd68224c0ec7f1
7
- data.tar.gz: 19921c8c23d8ceee3f00a304f7b8e98d1f0229759e186cd25faa507b45633f2e5fb2e382c529697ea8f6aa6f51e13f81ec77f84748f79b2eb9ca83f5ae7702db
6
+ metadata.gz: 59e687f40b55f56ad37b478505f357065c1c0237453fd2a97de8b03f525a28365b4daee4ee3b36de7927f4fcfb448b590071c1b9f7776a6751fcaf975399e2ec
7
+ data.tar.gz: 75b5e64e86f4de6168804682705b105bec73cb59ca6304afc1cf39deb5ca7ea988b257a9dca6f4bbc3e00ba56b8614986b5d128829eb762ddc90a9ff3ba388f2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2024-02-03
4
+
5
+ - Fixed Exponential strategy to just return the list weight if the item has a nil position
6
+
3
7
  ## [0.1.0] - 2024-02-01
4
8
 
5
9
  - Initial release
@@ -29,6 +29,10 @@ module WeightedListRank
29
29
  # @return [Float] the calculated score for the item, adjusted by the list's weight and the specified exponent.
30
30
  def calculate_score(list, item)
31
31
  rank_position = item.position
32
+
33
+ # if there are no positions, then just return the list weight
34
+ return list.weight if rank_position.nil?
35
+
32
36
  num_items = list.items.count
33
37
 
34
38
  contribution = ((num_items + 1 - rank_position)**exponent) / num_items.to_f
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WeightedListRank
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weighted_list_rank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Sherman