rating 2.0.0 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58836d050bdbccc7ed3cd471a8eebfe5bf3b6e16f3cfe6b5514b5e7ee724d59f
4
- data.tar.gz: 5b92166c762349531174a1a04a2784eb826f7f5a37d12d9f607a464482aae0b6
3
+ metadata.gz: cd8d857d3df1a7cba2e2b371faa45264c35fad7bcda32f44eac616315fe5d3e9
4
+ data.tar.gz: 037fd2f5f75889c55a8f22669a5f6fe8a27e9c996f8700763135220787514af0
5
5
  SHA512:
6
- metadata.gz: 3a3a39af0d990559f576a8a65e04f1d528bf89dd739e50b8127b43c3ec06b659e8cd2e62458337b903c6855fa6edad45ded96d5be94f67e5f5860d9904a5ae45
7
- data.tar.gz: dacdd84b9eaed47bdc1ceec1eceae4218f2ad5bb26c6b2f0ad81f4bf58ee3764d04b4317b8073f1211c00d7ee33bd525a5d3716362d74b5db8001907389aa501
6
+ metadata.gz: dd60527247cb213a23ea83c1b565dd57af6996db58347ef6cd9814c6dfd61881b154244f55583376bb25a54dfbf1bdfd1891f1ae14d8784cab267243dbe245c3
7
+ data.tar.gz: b57fcd16012cbc62414745d800141335cce88d8166f10cc227e8129fea90aa9cc7c1c5c107a5dfb8e370e5fae1adc027bbbe3a03b3f15a5178ebdb9ae2be8521
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v2.1.0
2
+
3
+ ### Updates
4
+
5
+ - `rating(scope:)` no longer triggers an N+1 when the `rating_records` association is already loaded.
6
+
1
7
  ## v2.0.0
2
8
 
3
9
  ### Break Changes
@@ -37,7 +37,17 @@ module Rating
37
37
  end
38
38
 
39
39
  def rating(scope: nil)
40
- rating_records.find_by scopeable: scope
40
+ if rating_records.loaded?
41
+ scopeable_id = scope&.id
42
+ clazz = scope&.class&.base_class
43
+ scopeable_type = clazz&.name
44
+
45
+ rating_records.detect do |record|
46
+ record.scopeable_id == scopeable_id && record.scopeable_type == scopeable_type
47
+ end
48
+ else
49
+ rating_records.find_by(scopeable: scope)
50
+ end
41
51
  end
42
52
 
43
53
  def rating_warm_up(scoping: nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rating
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rating
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
@@ -65,5 +65,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements: []
66
66
  rubygems_version: 3.6.9
67
67
  specification_version: 4
68
- summary: A true Bayesian rating system with scope and cache enabled.
68
+ summary: A confidence-based rating system with scope and cache enabled.
69
69
  test_files: []