diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a600c9..51ff4f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.10.0 + +### News + +- Add option `where` to be able adds conditions on `Rating::Rate`. + ## v0.9.0 ### News diff --git a/Gemfile.lock b/Gemfile.lock index 93658c2..b56d84c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rating (0.9.0) + rating (0.10.0) activerecord GEM diff --git a/README.md b/README.md index 754aa28..4230006 100644 --- a/README.md +++ b/README.md @@ -406,6 +406,22 @@ 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`. +### where + +The `where` option can be used to filter the `Rating::Rate` records used to create the final `Rating::Rating`. You can filter only approved rates, for exemplo: + +```ruby +rating where: 'approved = true' + +author = User.last +resource = Article.last + +author.rate resource, 1, extra_scope: { approved: false } +author.rate resource, 5, extra_scope: { approved: true } +``` + +As you can see, now, only the rate with value `5` will be included on the final rating. + ### References - [Evan Miller](http://www.evanmiller.org/ranking-items-with-star-ratings.html) diff --git a/lib/rating/version.rb b/lib/rating/version.rb index 2df5fdc..22598ef 100644 --- a/lib/rating/version.rb +++ b/lib/rating/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Rating - VERSION = '0.9.0' + VERSION = '0.10.0' end