main
Washington Botelho 2019-12-20 16:45:20 -03:00
parent e84b9b13a5
commit 4c92dfad30
No known key found for this signature in database
GPG Key ID: 5DE4F42A8F073617
4 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,9 @@
## v0.10.0
### News
- Add option `where` to be able adds conditions on `Rating::Rate`.
## v0.9.0
### News

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
rating (0.9.0)
rating (0.10.0)
activerecord
GEM

View File

@ -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)

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Rating
VERSION = '0.9.0'
VERSION = '0.10.0'
end