From c7ce1d256a1256ac77bd600ac1cf6c43c9c95638 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Mon, 5 Mar 2018 20:34:10 -0300 Subject: [PATCH] v0.8.0 --- CHANGELOG.md | 6 ++++++ Gemfile.lock | 8 ++++---- README.md | 18 ++++++++++++++++++ lib/rating/version.rb | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea75799..63c7102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.8.0 + +### News + +- Adds `unscoped_rating` option to calculate the rating counting all resource record ignoring the scope. + ## v0.7.0 ### News diff --git a/Gemfile.lock b/Gemfile.lock index 58cbf2f..859afd1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rating (0.7.0) + rating (0.8.0) activerecord (>= 4.2, < 6) GEM @@ -40,7 +40,7 @@ GEM crass (1.0.3) database_cleaner (1.6.2) diff-lcs (1.3) - erubi (1.7.0) + erubi (1.7.1) factory_bot (4.8.2) activesupport (>= 3.0.0) factory_bot_rails (4.8.2) @@ -100,9 +100,9 @@ GEM rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) - rubocop (0.52.1) + rubocop (0.53.0) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) + parser (>= 2.5) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) diff --git a/README.md b/README.md index f85754c..8bab7ef 100644 --- a/README.md +++ b/README.md @@ -392,6 +392,24 @@ rating: - scope_2 ``` +### Unscoped Rating + +All rating values are grouped by the scope, but you can disable it and group all of them. + +```ruby +rating unscoped_rating: true + +author = User.last +resource = Article.last +scope = Category.last + +author.rate resource, 1, scope: scope +author.rate resource, 2, scope: scope +author.rate resource, 3 +``` + +Now the `sum` will be `6` and the `total` will be `3` because all rating will be calculated into just one rating record ignoring the `scopeable` object. The rating record is always saved on the record with `scopeable` as `nil`. + ## Love it! Via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=rating) or [Patreon](https://www.patreon.com/wbotelhos). Thanks! (: diff --git a/lib/rating/version.rb b/lib/rating/version.rb index 572ffb8..c902e0a 100644 --- a/lib/rating/version.rb +++ b/lib/rating/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Rating - VERSION = '0.7.0' + VERSION = '0.8.0' end