rating 0.9.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -10
- data/README.md +40 -16
- data/lib/rating/models/rating/extension.rb +1 -2
- data/lib/rating/models/rating/rate.rb +3 -7
- data/lib/rating/models/rating/rating.rb +25 -5
- data/lib/rating/version.rb +1 -1
- metadata +56 -122
- data/spec/config/rate_table_spec.rb +0 -17
- data/spec/config/rating_table_spec.rb +0 -17
- data/spec/config/validations_spec.rb +0 -33
- data/spec/factories/article.rb +0 -7
- data/spec/factories/author.rb +0 -7
- data/spec/factories/category.rb +0 -7
- data/spec/factories/comment.rb +0 -5
- data/spec/factories/global.rb +0 -6
- data/spec/factories/rating/rate.rb +0 -10
- data/spec/factories/rating/rating.rb +0 -12
- data/spec/models/extension/after_create_spec.rb +0 -47
- data/spec/models/extension/order_by_rating_spec.rb +0 -180
- data/spec/models/extension/rate_for_spec.rb +0 -41
- data/spec/models/extension/rate_spec.rb +0 -60
- data/spec/models/extension/rated_question_spec.rb +0 -48
- data/spec/models/extension/rated_records_spec.rb +0 -12
- data/spec/models/extension/rated_spec.rb +0 -50
- data/spec/models/extension/rates_records_spec.rb +0 -12
- data/spec/models/extension/rates_spec.rb +0 -50
- data/spec/models/extension/rating_records_spec.rb +0 -12
- data/spec/models/extension/rating_spec.rb +0 -40
- data/spec/models/extension/rating_warm_up_spec.rb +0 -115
- data/spec/models/extension/unscoped_rating_spec.rb +0 -121
- data/spec/models/rate/create_spec.rb +0 -364
- data/spec/models/rate/rate_for_spec.rb +0 -107
- data/spec/models/rate_spec.rb +0 -28
- data/spec/models/rating/averager_data_spec.rb +0 -32
- data/spec/models/rating/data_spec.rb +0 -48
- data/spec/models/rating/update_rating_spec.rb +0 -48
- data/spec/models/rating/values_data_spec.rb +0 -40
- data/spec/models/rating_spec.rb +0 -24
- data/spec/rails_helper.rb +0 -17
- data/spec/support/common.rb +0 -22
- data/spec/support/database_cleaner.rb +0 -19
- data/spec/support/db/migrate/add_comment_on_rating_rates_table.rb +0 -8
- data/spec/support/db/migrate/add_extra_fields_on_rating_rates_table.rb +0 -8
- data/spec/support/db/migrate/create_articles_table.rb +0 -9
- data/spec/support/db/migrate/create_authors_table.rb +0 -9
- data/spec/support/db/migrate/create_categories_table.rb +0 -12
- data/spec/support/db/migrate/create_comments_table.rb +0 -7
- data/spec/support/db/migrate/create_globals_table.rb +0 -8
- data/spec/support/db/migrate/create_rates_table.rb +0 -19
- data/spec/support/db/migrate/create_rating_table.rb +0 -20
- data/spec/support/db/migrate/create_review_ratings_table.rb +0 -17
- data/spec/support/db/migrate/create_reviews_table.rb +0 -15
- data/spec/support/factory_bot.rb +0 -9
- data/spec/support/migrate.rb +0 -20
- data/spec/support/models/article.rb +0 -7
- data/spec/support/models/author.rb +0 -5
- data/spec/support/models/category.rb +0 -6
- data/spec/support/models/comment.rb +0 -5
- data/spec/support/models/global.rb +0 -7
- data/spec/support/models/review.rb +0 -5
- data/spec/support/models/review_rating.rb +0 -4
- data/spec/support/shared_context/with_database_records.rb +0 -20
- data/spec/support/shoulda.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 107d28dc3f0be409a1684eebea163b6dcf6cc57d801f7dcd88bca4f0bcf4f662
|
4
|
+
data.tar.gz: af591a933ee3bf23720cd054c33968ec9fbba3f21cbd9d117dd1628f0b6cebb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3dc424ab1155b6a7f6aa309b461015c7d06b2786c172d55b03b29052a3643d098fe78dde4a9c7edf2b564ea324451e5ad1a12373769caa7b6520cb0b5def8d
|
7
|
+
data.tar.gz: b92eaadfdaa4cca67eca6e3a5550333080541d93b1a48e01dace83bc858969fc718f60123c40353c15bf3ec6c42166b2359d9d82e05b315454a4ca74b91b32be
|
data/CHANGELOG.md
CHANGED
@@ -1,48 +1,74 @@
|
|
1
|
+
## v0.12.0
|
2
|
+
|
3
|
+
### News
|
4
|
+
|
5
|
+
- Officially Supports Postgres;
|
6
|
+
|
7
|
+
### Updates
|
8
|
+
|
9
|
+
- Migrates the CI to GitHub Actions;
|
10
|
+
- This gem does not depends on `git` package anymore;
|
11
|
+
- Makes this gem requires MFA for security;
|
12
|
+
- Adds coverage test;
|
13
|
+
- The method `rated?` now uses a better query;
|
14
|
+
|
15
|
+
## v0.11.0
|
16
|
+
|
17
|
+
### Updates
|
18
|
+
|
19
|
+
- Same rate value hits DB to update metadata.
|
20
|
+
|
21
|
+
## v0.10.0
|
22
|
+
|
23
|
+
### News
|
24
|
+
|
25
|
+
- Add option `where` to be able adds conditions on `Rating::Rate`.
|
26
|
+
|
1
27
|
## v0.9.0
|
2
28
|
|
3
29
|
### News
|
4
30
|
|
5
|
-
- Order index keys of template the same way Rails does the query;
|
31
|
+
- Order index keys of the template the same way Rails does the query;
|
6
32
|
- Limits the `_type` columns to avoid overflow bytes in DBs like MySQL < 5.7.
|
7
33
|
|
8
34
|
### Updates
|
9
35
|
|
10
|
-
- Update
|
11
|
-
- Update
|
36
|
+
- Update Ruby to 2.6.5;
|
37
|
+
- Update ActiveRecord to the last version;
|
12
38
|
|
13
39
|
## v0.8.0
|
14
40
|
|
15
41
|
### News
|
16
42
|
|
17
|
-
- Adds `unscoped_rating` option to calculate the rating counting all resource
|
43
|
+
- Adds `unscoped_rating` option to calculate the rating by counting all resource records ignoring the scope.
|
18
44
|
|
19
45
|
## v0.7.0
|
20
46
|
|
21
47
|
### News
|
22
48
|
|
23
49
|
- Support to configure `uniqueness` validation via YAML into Rating::Rate model;
|
24
|
-
- Support
|
50
|
+
- Support multiple scopes via `extra_scopes` option.
|
25
51
|
|
26
52
|
### Updates
|
27
53
|
|
28
|
-
- Reverts v0.6.0, since we need this validation because we cannot edit the Rate model by
|
54
|
+
- Reverts v0.6.0, since we need this validation because we cannot edit the Rate model by ourselves.
|
29
55
|
|
30
56
|
## v0.6.0
|
31
57
|
|
32
58
|
### Updates
|
33
59
|
|
34
|
-
- The author unique validations
|
60
|
+
- The author's unique validations were removed to enable custom validations
|
35
61
|
|
36
62
|
## v0.5.0
|
37
63
|
|
38
64
|
### News
|
39
65
|
|
40
|
-
- Adds `rating.yml` config to support
|
41
|
-
- Adds `scoping` option to support
|
66
|
+
- Adds `rating.yml` config to support changing the tables where Rating will write the data;
|
67
|
+
- Adds `scoping` option to support generating zero-based rating via scope.
|
42
68
|
|
43
69
|
### Updates
|
44
70
|
|
45
|
-
- The
|
71
|
+
- The migration was separated in two to improve troubleshooting. [#1](https://github.com/wbotelhos/rating/pull/1) by [iondrimba](https://github.com/iondrimba)
|
46
72
|
|
47
73
|
## v0.4.0
|
48
74
|
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Rating
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![CI](https://github.com/wbotelhos/rating/workflows/CI/badge.svg)](https://github.com/wbotelhos/rating/actions)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rating.svg)](https://badge.fury.io/rb/rating)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/cc5efe8b06bc1d5e9e8a/maintainability)](https://codeclimate.com/github/wbotelhos/rating/maintainability)
|
6
|
-
[![
|
6
|
+
[![codecov](https://codecov.io/gh/wbotelhos/rating/branch/master/graph/badge.svg?token=QJSHUOULEG)](https://codecov.io/gh/wbotelhos/rating)
|
7
|
+
[![Sponsor](https://img.shields.io/badge/sponsor-%3C3-green)](https://www.patreon.com/wbotelhos)
|
7
8
|
|
8
9
|
A true Bayesian rating system with scope and cache enabled.
|
9
10
|
|
@@ -51,15 +52,15 @@ Add the following code on your `Gemfile` and run `bundle install`:
|
|
51
52
|
gem 'rating'
|
52
53
|
```
|
53
54
|
|
54
|
-
Run the following task to create
|
55
|
+
Run the following task to create the Rating migration:
|
55
56
|
|
56
|
-
```
|
57
|
+
```sh
|
57
58
|
rails g rating:install
|
58
59
|
```
|
59
60
|
|
60
61
|
Then execute the migrations to create the to create tables `rating_rates` and `rating_ratings`:
|
61
62
|
|
62
|
-
```
|
63
|
+
```sh
|
63
64
|
rake db:migrate
|
64
65
|
```
|
65
66
|
|
@@ -138,24 +139,20 @@ author.rated? resource
|
|
138
139
|
|
139
140
|
### rates
|
140
141
|
|
141
|
-
|
142
|
+
All rating received.
|
142
143
|
|
143
144
|
```ruby
|
144
|
-
|
145
|
-
|
146
|
-
resource.rates
|
145
|
+
Article.first.rates
|
147
146
|
```
|
148
147
|
|
149
148
|
It will return a collection of `Rate` object.
|
150
149
|
|
151
150
|
### rated
|
152
151
|
|
153
|
-
|
152
|
+
All rating given.
|
154
153
|
|
155
154
|
```ruby
|
156
|
-
|
157
|
-
|
158
|
-
author.rated
|
155
|
+
Author.first.rated
|
159
156
|
```
|
160
157
|
|
161
158
|
It will return a collection of `Rate` object.
|
@@ -349,7 +346,7 @@ If you need to warm up a record with scope, you need to setup the `scoping` rela
|
|
349
346
|
|
350
347
|
```ruby
|
351
348
|
class Resource < ApplicationRecord
|
352
|
-
|
349
|
+
rating scoping: :categories
|
353
350
|
end
|
354
351
|
```
|
355
352
|
|
@@ -394,7 +391,7 @@ rating:
|
|
394
391
|
|
395
392
|
### Unscoped Rating
|
396
393
|
|
397
|
-
All rating values are grouped by
|
394
|
+
All rating values are grouped by its own scope, but you can disable it and group all of them together.
|
398
395
|
|
399
396
|
```ruby
|
400
397
|
rating unscoped_rating: true
|
@@ -408,7 +405,34 @@ author.rate resource, 2, scope: scope
|
|
408
405
|
author.rate resource, 3
|
409
406
|
```
|
410
407
|
|
411
|
-
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.
|
408
|
+
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.
|
409
|
+
The rating record is *always* saved on the record with `scopeable` as `nil`.
|
410
|
+
|
411
|
+
### where
|
412
|
+
|
413
|
+
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:
|
414
|
+
|
415
|
+
```ruby
|
416
|
+
rating where: 'approved = true'
|
417
|
+
|
418
|
+
author = User.last
|
419
|
+
resource = Article.last
|
420
|
+
|
421
|
+
author.rate resource, 1, extra_scope: { approved: false }
|
422
|
+
author.rate resource, 5, extra_scope: { approved: true }
|
423
|
+
```
|
424
|
+
|
425
|
+
As you can see, now, only the rate with value `5` will be included on the final rating.
|
426
|
+
|
427
|
+
### Specs
|
428
|
+
|
429
|
+
To run all specs, run the following rakes:
|
430
|
+
|
431
|
+
```sh
|
432
|
+
bundle exec rake spec
|
433
|
+
bundle exec rake spec_config
|
434
|
+
bundle exec rake spec_config_with_extra_scopes
|
435
|
+
```
|
412
436
|
|
413
437
|
### References
|
414
438
|
|
@@ -20,9 +20,8 @@ module Rating
|
|
20
20
|
Rate.rate_for author: self, extra_scopes: extra_scopes, resource: resource, scopeable: scope
|
21
21
|
end
|
22
22
|
|
23
|
-
# TODO: use exists for performance
|
24
23
|
def rated?(resource, extra_scopes: {}, scope: nil)
|
25
|
-
|
24
|
+
Rate.exists?(extra_scopes.merge(author: self, resource: resource, scopeable: scope))
|
26
25
|
end
|
27
26
|
|
28
27
|
def rates(extra_scopes: {}, scope: nil)
|
@@ -19,12 +19,10 @@ module Rating
|
|
19
19
|
scope: ::Rating::Config.validations['rate']['scope'].map(&:to_sym),
|
20
20
|
}
|
21
21
|
|
22
|
-
def self.create(author:, extra_scopes:, metadata:, resource:, scopeable: nil
|
22
|
+
def self.create(author:, extra_scopes:, metadata:, resource:, value:, scopeable: nil)
|
23
23
|
attributes = { author: author, resource: resource, scopeable: scopeable }.merge(extra_scopes)
|
24
24
|
record = find_or_initialize_by(attributes)
|
25
25
|
|
26
|
-
return record if record.persisted? && value == record.value
|
27
|
-
|
28
26
|
metadata.each { |k, v| record[k] = v } if metadata.present?
|
29
27
|
|
30
28
|
record.value = value
|
@@ -33,10 +31,8 @@ module Rating
|
|
33
31
|
record
|
34
32
|
end
|
35
33
|
|
36
|
-
def self.rate_for(author:, extra_scopes: {},
|
37
|
-
|
38
|
-
|
39
|
-
find_by attributes
|
34
|
+
def self.rate_for(author:, resource:, extra_scopes: {}, scopeable: nil)
|
35
|
+
find_by extra_scopes.merge(author: author, resource: resource, scopeable: scopeable)
|
40
36
|
end
|
41
37
|
|
42
38
|
private
|
@@ -29,7 +29,10 @@ module Rating
|
|
29
29
|
(CAST(#{total_count} AS DECIMAL(17, 14)) / #{distinct_count}) count_avg,
|
30
30
|
COALESCE(AVG(value), 0) rating_avg
|
31
31
|
FROM #{rate_table_name}
|
32
|
-
WHERE
|
32
|
+
WHERE
|
33
|
+
resource_type = :resource_type
|
34
|
+
#{scope_type_query(resource, scopeable)}
|
35
|
+
#{scope_where_query(resource)}
|
33
36
|
).squish
|
34
37
|
|
35
38
|
execute_sql [sql, values]
|
@@ -54,7 +57,11 @@ module Rating
|
|
54
57
|
COALESCE(SUM(value), 0) rating_sum,
|
55
58
|
COUNT(1) rating_count
|
56
59
|
FROM #{rate_table_name}
|
57
|
-
WHERE
|
60
|
+
WHERE
|
61
|
+
resource_type = ?
|
62
|
+
AND resource_id = ?
|
63
|
+
#{scope_type_and_id_query(resource, scopeable)}
|
64
|
+
#{scope_where_query(resource)}
|
58
65
|
).squish
|
59
66
|
|
60
67
|
values = [sql, resource.class.base_class.name, resource.id]
|
@@ -86,8 +93,8 @@ module Rating
|
|
86
93
|
resource_rating_avg = values.rating_avg
|
87
94
|
resource_rating_count = values.rating_count.to_f
|
88
95
|
|
89
|
-
(resource_rating_count / (resource_rating_count + count_avg)) * resource_rating_avg +
|
90
|
-
(count_avg / (resource_rating_count + count_avg)) * resource_type_rating_avg
|
96
|
+
((resource_rating_count / (resource_rating_count + count_avg)) * resource_rating_avg) +
|
97
|
+
((count_avg / (resource_rating_count + count_avg)) * resource_type_rating_avg)
|
91
98
|
end
|
92
99
|
|
93
100
|
def execute_sql(sql)
|
@@ -104,7 +111,10 @@ module Rating
|
|
104
111
|
%((
|
105
112
|
SELECT GREATEST(#{count}, 1)
|
106
113
|
FROM #{rate_table_name}
|
107
|
-
WHERE
|
114
|
+
WHERE
|
115
|
+
resource_type = :resource_type
|
116
|
+
#{scope_type_query(resource, scopeable)}
|
117
|
+
#{scope_where_query(resource)}
|
108
118
|
))
|
109
119
|
end
|
110
120
|
|
@@ -124,6 +134,16 @@ module Rating
|
|
124
134
|
|
125
135
|
'AND scopeable_type = ? AND scopeable_id = ?'
|
126
136
|
end
|
137
|
+
|
138
|
+
def scope_where_query(resource)
|
139
|
+
return '' if where_condition(resource).blank?
|
140
|
+
|
141
|
+
"AND #{where_condition(resource)}"
|
142
|
+
end
|
143
|
+
|
144
|
+
def where_condition(resource)
|
145
|
+
resource.rating_options[:where]
|
146
|
+
end
|
127
147
|
end
|
128
148
|
end
|
129
149
|
end
|
data/lib/rating/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rating
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: database_cleaner
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: debug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: factory_bot_rails
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +95,7 @@ dependencies:
|
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: pg
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
@@ -108,6 +136,20 @@ dependencies:
|
|
108
136
|
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rails
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: rubocop-rspec
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +182,10 @@ description: A true Bayesian rating system with scope and cache enabled.
|
|
140
182
|
email: wbotelhos@gmail.com
|
141
183
|
executables: []
|
142
184
|
extensions: []
|
143
|
-
extra_rdoc_files:
|
185
|
+
extra_rdoc_files:
|
186
|
+
- CHANGELOG.md
|
187
|
+
- LICENSE
|
188
|
+
- README.md
|
144
189
|
files:
|
145
190
|
- CHANGELOG.md
|
146
191
|
- LICENSE
|
@@ -154,67 +199,12 @@ files:
|
|
154
199
|
- lib/rating/models/rating/rate.rb
|
155
200
|
- lib/rating/models/rating/rating.rb
|
156
201
|
- lib/rating/version.rb
|
157
|
-
- spec/config/rate_table_spec.rb
|
158
|
-
- spec/config/rating_table_spec.rb
|
159
|
-
- spec/config/validations_spec.rb
|
160
|
-
- spec/factories/article.rb
|
161
|
-
- spec/factories/author.rb
|
162
|
-
- spec/factories/category.rb
|
163
|
-
- spec/factories/comment.rb
|
164
|
-
- spec/factories/global.rb
|
165
|
-
- spec/factories/rating/rate.rb
|
166
|
-
- spec/factories/rating/rating.rb
|
167
|
-
- spec/models/extension/after_create_spec.rb
|
168
|
-
- spec/models/extension/order_by_rating_spec.rb
|
169
|
-
- spec/models/extension/rate_for_spec.rb
|
170
|
-
- spec/models/extension/rate_spec.rb
|
171
|
-
- spec/models/extension/rated_question_spec.rb
|
172
|
-
- spec/models/extension/rated_records_spec.rb
|
173
|
-
- spec/models/extension/rated_spec.rb
|
174
|
-
- spec/models/extension/rates_records_spec.rb
|
175
|
-
- spec/models/extension/rates_spec.rb
|
176
|
-
- spec/models/extension/rating_records_spec.rb
|
177
|
-
- spec/models/extension/rating_spec.rb
|
178
|
-
- spec/models/extension/rating_warm_up_spec.rb
|
179
|
-
- spec/models/extension/unscoped_rating_spec.rb
|
180
|
-
- spec/models/rate/create_spec.rb
|
181
|
-
- spec/models/rate/rate_for_spec.rb
|
182
|
-
- spec/models/rate_spec.rb
|
183
|
-
- spec/models/rating/averager_data_spec.rb
|
184
|
-
- spec/models/rating/data_spec.rb
|
185
|
-
- spec/models/rating/update_rating_spec.rb
|
186
|
-
- spec/models/rating/values_data_spec.rb
|
187
|
-
- spec/models/rating_spec.rb
|
188
|
-
- spec/rails_helper.rb
|
189
|
-
- spec/support/common.rb
|
190
|
-
- spec/support/database_cleaner.rb
|
191
|
-
- spec/support/db/migrate/add_comment_on_rating_rates_table.rb
|
192
|
-
- spec/support/db/migrate/add_extra_fields_on_rating_rates_table.rb
|
193
|
-
- spec/support/db/migrate/create_articles_table.rb
|
194
|
-
- spec/support/db/migrate/create_authors_table.rb
|
195
|
-
- spec/support/db/migrate/create_categories_table.rb
|
196
|
-
- spec/support/db/migrate/create_comments_table.rb
|
197
|
-
- spec/support/db/migrate/create_globals_table.rb
|
198
|
-
- spec/support/db/migrate/create_rates_table.rb
|
199
|
-
- spec/support/db/migrate/create_rating_table.rb
|
200
|
-
- spec/support/db/migrate/create_review_ratings_table.rb
|
201
|
-
- spec/support/db/migrate/create_reviews_table.rb
|
202
|
-
- spec/support/factory_bot.rb
|
203
|
-
- spec/support/migrate.rb
|
204
|
-
- spec/support/models/article.rb
|
205
|
-
- spec/support/models/author.rb
|
206
|
-
- spec/support/models/category.rb
|
207
|
-
- spec/support/models/comment.rb
|
208
|
-
- spec/support/models/global.rb
|
209
|
-
- spec/support/models/review.rb
|
210
|
-
- spec/support/models/review_rating.rb
|
211
|
-
- spec/support/shared_context/with_database_records.rb
|
212
|
-
- spec/support/shoulda.rb
|
213
202
|
homepage: https://github.com/wbotelhos/rating
|
214
203
|
licenses:
|
215
204
|
- MIT
|
216
|
-
metadata:
|
217
|
-
|
205
|
+
metadata:
|
206
|
+
rubygems_mfa_required: 'true'
|
207
|
+
post_install_message:
|
218
208
|
rdoc_options: []
|
219
209
|
require_paths:
|
220
210
|
- lib
|
@@ -229,64 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
219
|
- !ruby/object:Gem::Version
|
230
220
|
version: '0'
|
231
221
|
requirements: []
|
232
|
-
rubygems_version: 3.
|
233
|
-
signing_key:
|
222
|
+
rubygems_version: 3.3.12
|
223
|
+
signing_key:
|
234
224
|
specification_version: 4
|
235
225
|
summary: A true Bayesian rating system with scope and cache enabled.
|
236
|
-
test_files:
|
237
|
-
- spec/config/rate_table_spec.rb
|
238
|
-
- spec/config/validations_spec.rb
|
239
|
-
- spec/config/rating_table_spec.rb
|
240
|
-
- spec/models/rate/rate_for_spec.rb
|
241
|
-
- spec/models/rate/create_spec.rb
|
242
|
-
- spec/models/rating/averager_data_spec.rb
|
243
|
-
- spec/models/rating/data_spec.rb
|
244
|
-
- spec/models/rating/update_rating_spec.rb
|
245
|
-
- spec/models/rating/values_data_spec.rb
|
246
|
-
- spec/models/extension/rated_records_spec.rb
|
247
|
-
- spec/models/extension/rating_spec.rb
|
248
|
-
- spec/models/extension/rated_question_spec.rb
|
249
|
-
- spec/models/extension/rating_warm_up_spec.rb
|
250
|
-
- spec/models/extension/order_by_rating_spec.rb
|
251
|
-
- spec/models/extension/unscoped_rating_spec.rb
|
252
|
-
- spec/models/extension/rate_spec.rb
|
253
|
-
- spec/models/extension/rate_for_spec.rb
|
254
|
-
- spec/models/extension/after_create_spec.rb
|
255
|
-
- spec/models/extension/rates_spec.rb
|
256
|
-
- spec/models/extension/rating_records_spec.rb
|
257
|
-
- spec/models/extension/rated_spec.rb
|
258
|
-
- spec/models/extension/rates_records_spec.rb
|
259
|
-
- spec/models/rating_spec.rb
|
260
|
-
- spec/models/rate_spec.rb
|
261
|
-
- spec/support/migrate.rb
|
262
|
-
- spec/support/shoulda.rb
|
263
|
-
- spec/support/factory_bot.rb
|
264
|
-
- spec/support/models/article.rb
|
265
|
-
- spec/support/models/category.rb
|
266
|
-
- spec/support/models/author.rb
|
267
|
-
- spec/support/models/review.rb
|
268
|
-
- spec/support/models/comment.rb
|
269
|
-
- spec/support/models/global.rb
|
270
|
-
- spec/support/models/review_rating.rb
|
271
|
-
- spec/support/common.rb
|
272
|
-
- spec/support/db/migrate/create_categories_table.rb
|
273
|
-
- spec/support/db/migrate/create_authors_table.rb
|
274
|
-
- spec/support/db/migrate/create_review_ratings_table.rb
|
275
|
-
- spec/support/db/migrate/create_articles_table.rb
|
276
|
-
- spec/support/db/migrate/create_rating_table.rb
|
277
|
-
- spec/support/db/migrate/add_comment_on_rating_rates_table.rb
|
278
|
-
- spec/support/db/migrate/add_extra_fields_on_rating_rates_table.rb
|
279
|
-
- spec/support/db/migrate/create_reviews_table.rb
|
280
|
-
- spec/support/db/migrate/create_comments_table.rb
|
281
|
-
- spec/support/db/migrate/create_globals_table.rb
|
282
|
-
- spec/support/db/migrate/create_rates_table.rb
|
283
|
-
- spec/support/database_cleaner.rb
|
284
|
-
- spec/support/shared_context/with_database_records.rb
|
285
|
-
- spec/factories/article.rb
|
286
|
-
- spec/factories/category.rb
|
287
|
-
- spec/factories/rating/rate.rb
|
288
|
-
- spec/factories/rating/rating.rb
|
289
|
-
- spec/factories/author.rb
|
290
|
-
- spec/factories/comment.rb
|
291
|
-
- spec/factories/global.rb
|
292
|
-
- spec/rails_helper.rb
|
226
|
+
test_files: []
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
|
-
RSpec.describe Rating::Config, '.rate_table' do
|
6
|
-
if ENV['CONFIG_ENABLED'] != 'true'
|
7
|
-
context 'when rating.yml does not exist' do
|
8
|
-
it { expect(subject.rate_table).to eq 'rating_rates' }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
if ENV['CONFIG_ENABLED'] == 'true'
|
13
|
-
context 'when rating.yml exists' do
|
14
|
-
it { expect(subject.rate_table).to eq 'reviews' }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
|
-
RSpec.describe Rating::Config, '.rating_table' do
|
6
|
-
if ENV['CONFIG_ENABLED'] != 'true'
|
7
|
-
context 'when rating.yml does not exist' do
|
8
|
-
it { expect(subject.rating_table).to eq 'rating_ratings' }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
if ENV['CONFIG_ENABLED'] == 'true'
|
13
|
-
context 'when rating.yml exists' do
|
14
|
-
it { expect(subject.rating_table).to eq 'review_ratings' }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
|
-
RSpec.describe Rating::Config, '.validations' do
|
6
|
-
if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] != 'true'
|
7
|
-
context 'when rating.yml does not exist' do
|
8
|
-
it do
|
9
|
-
expect(subject.validations).to eq({
|
10
|
-
rate: {
|
11
|
-
case_sensitive: false,
|
12
|
-
scope: %w[author_type resource_id resource_type scopeable_id scopeable_type],
|
13
|
-
},
|
14
|
-
}.deep_stringify_keys
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] == 'true'
|
21
|
-
context 'when rating.yml exists' do
|
22
|
-
it do
|
23
|
-
expect(subject.validations).to eq({
|
24
|
-
rate: {
|
25
|
-
case_sensitive: false,
|
26
|
-
scope: %w[author_type resource_id resource_type scopeable_id scopeable_type scope_1 scope_2],
|
27
|
-
},
|
28
|
-
}.deep_stringify_keys
|
29
|
-
)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/factories/article.rb
DELETED
data/spec/factories/author.rb
DELETED
data/spec/factories/category.rb
DELETED
data/spec/factories/comment.rb
DELETED