checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 86833f54644bc8f78e5a3a731916543601e7eefd907c11d4157d9d7832ba993b
4
- data.tar.gz: a897c0c087c4310319cb707c6799332b64055c417c085d6a7d32d0a0ffbc1404
3
+ metadata.gz: cbc95c26a6972a59da6d0daa765491622783a60cfc8dd0961109b82839b0af77
4
+ data.tar.gz: 9f62f3d6484cdf8002172106970954fa053784844a6fa6084b2aee3baadf8e7b
5
5
SHA512:
6
- metadata.gz: d7f62ba90536c350bd2b05c67db6f9f5ad898fe90696bc96ca5faff098e58574f0230968e6c3725a17383439f80a1c3d9b7a8827101783c765d23e34a384ce6f
7
- data.tar.gz: a4e4d4e1c00d3543eb0a10f8b632f56d9492f8345e744a0d8724ffbd747ae64eaa13839ed7d90170531e4f82fba0da7fc6005da80d9142ebaa26105611a58844
6
+ metadata.gz: e6913aca804eeb31ab4bb877b74b2826b50596e7b3a087eb162c49d46dc6df2a162ab8ca683e8251a1c056c798d12597294125acea2f102a91150baef4b31a4c
7
+ data.tar.gz: ab487315635024cb2fcbb3b6cea388188b01ad31e0cfbcaf6e9e9513f35f1ad53c035eeb67927bda4796265bf6459eed6b14028bec6faf22066c3257907df5a1
data/app/seeds/{reviews.rb → review_seeds.rb} RENAMED
@@ -3,17 +3,26 @@ module Workarea
3
3
def perform
4
4
puts 'Adding reviews...'
5
5
6
- Workarea::Catalog::Product.all.each_by(100) do |product|
7
- rand(10).times { create_review(product) }
6
+ Sidekiq::Callbacks.disable do
7
+ create_reviews_for_catalog
8
+ create_review_request_email_content
8
9
end
9
-
10
- create_review_request_email_content
11
10
end
12
11
13
12
private
14
13
14
+ def create_reviews_for_catalog
15
+ Workarea::Catalog::Product.all.each_by(100) do |product|
16
+ reviews = Array.new(rand(10)) { create_review(product) }
17
+ next unless reviews.size > 0
18
+
19
+ Workarea::Review.collection.insert_many(reviews.map(&:as_document))
20
+ UpdateProductReviewData.perform_async(product.id)
21
+ end
22
+ end
23
+
15
24
def create_review(product)
16
- Workarea::Review.create!(
25
+ Workarea::Review.new(
17
26
product_id: product.id,
18
27
user_id: BSON::ObjectId.new,
19
28
rating: rand(5) + 1,
@@ -21,7 +30,9 @@ module Workarea
21
30
body: Faker::Lorem.paragraph,
22
31
approved: [true, false].sample,
23
32
user_info: Faker::Internet.user_name,
24
- verified: [true, false].sample
33
+ verified: [true, false].sample,
34
+ created_at: rand(45).days.ago,
35
+ updated_at: Time.current
25
36
)
26
37
end
27
38
data/lib/workarea/reviews/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
module Workarea
2
2
module Reviews
3
- VERSION = '3.0.9'.freeze
3
+ VERSION = '3.0.10'.freeze
4
4
end
5
5
end
data/test/helpers/workarea/storefront/reviews_helper_test.rb CHANGED
@@ -4,7 +4,7 @@ module Workarea
4
4
module Storefront
5
5
class ReviewsHelperTest < ViewTest
6
6
def test_rating_stars_displays_correct_rating
7
- assert_match(/1\.0 out of 5 stars/, rating_stars(1))
7
+ assert_match(/1(?:\.0)? out of 5 stars/, rating_stars(1))
8
8
assert_match(/2\.5 out of 5 stars/, rating_stars(2.5))
9
9
assert_match(/4\.25 out of 5 stars/, rating_stars(4.251))
10
10
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: workarea-reviews
3
3
version: !ruby/object:Gem::Version
4
- version: 3.0.9
4
+ version: 3.0.10
5
5
platform: ruby
6
6
authors:
7
7
- Ben Crouse
8
8
autorequire:
9
9
bindir: bin
10
10
cert_chain: []
11
- date: 2019-08-26 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: workarea
@@ -100,7 +100,7 @@ files:
100
100
- app/queries/workarea/search/admin_reviews.rb
101
101
- app/queries/workarea/search/category_browse.decorator
102
102
- app/queries/workarea/search/product_search.decorator
103
- - app/seeds/reviews.rb
103
+ - app/seeds/review_seeds.rb
104
104
- app/services/workarea/create_review.rb
105
105
- app/view_models/workarea/admin/product_view_model.decorator
106
106
- app/view_models/workarea/admin/review_view_model.rb