weighted_list_rank 0.1.0 → 0.1.2

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
  SHA256:
3
- metadata.gz: 7d6af0dabc07041ac8d52dade9dcaf6788e68d1b8809e85e5dc57d9cf032b83c
4
- data.tar.gz: 913262cd828e18bc68bc69d4f62bc422b17c2711d82de7132f887d2732d65534
3
+ metadata.gz: 1f50527ee43cba5bd55144f8c76bc4b702cd2e84a797008aa4bed9cfa9b055a9
4
+ data.tar.gz: 0427e71591900a28fadcc5e68dae0bfbd71c7b97b00896953b5ecaec80ccbad7
5
5
  SHA512:
6
- metadata.gz: e3d0d1f24a242c249337c9dd2889d0468bb616fbead79ebabdda1d7bf3ad629c962e6b004d0b7051933d91fb1a8f5aa15602c70858a9ed7b20bd68224c0ec7f1
7
- data.tar.gz: 19921c8c23d8ceee3f00a304f7b8e98d1f0229759e186cd25faa507b45633f2e5fb2e382c529697ea8f6aa6f51e13f81ec77f84748f79b2eb9ca83f5ae7702db
6
+ metadata.gz: 2da62414b58dafb3ac4e49cbc18e0cb1b24c09edb78e0888365a3ac68e16e764974a83be8379dabe3a4291673170d7d1e80429a1a1c97189aa7ee3f1edbae597
7
+ data.tar.gz: 545f22a6c95c3713698c743e7f5fb1f2495034fc57ee81b4a745a8d064594cc9fa818fd5481d6443152a51e1fdaa5a7f1f362e17297f72a345a6e59a36255d12
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2024-02-03
4
+
5
+ - Added list weight to rank result
6
+ -
7
+ ## [0.1.1] - 2024-02-03
8
+
9
+ - Fixed Exponential strategy to just return the list weight if the item has a nil position
10
+
3
11
  ## [0.1.0] - 2024-02-01
4
12
 
5
13
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weighted_list_rank (0.1.0)
4
+ weighted_list_rank (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -22,7 +22,7 @@ module WeightedListRank
22
22
  items[item.id] ||= {}
23
23
  # Ensure the list_details array exists, then append the new score detail
24
24
  items[item.id][:list_details] ||= []
25
- items[item.id][:list_details] << {list_id: list.id, score: score}
25
+ items[item.id][:list_details] << {list_id: list.id, score: score, weight: list.weight}
26
26
 
27
27
  # Ensure the total_score is initialized, then add the score
28
28
  items[item.id][:total_score] ||= 0
@@ -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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Sherman