Price owl#186
Open
om-ma wants to merge 15 commits into
Open
Conversation
added 8 commits
May 20, 2021 23:25
om-ma
commented
May 21, 2021
| self[:reviews_count] = reviews.count | ||
| self[:avg_rating] = if reviews_count > 0 | ||
| reviews.approved.sum(:rating).to_f / reviews_count | ||
| reviews.sum(:rating).to_f / reviews.count |
| scope :approved, -> { where(approved: true) } | ||
| scope :not_approved, -> { where(approved: false) } | ||
| scope :default_approval_filter, -> { Spree::Reviews::Config[:include_unapproved_reviews] ? all : approved } | ||
| scope :raiting_five, -> { where(rating: '5').count } |
Author
There was a problem hiding this comment.
change raiting_five to rating__with_five
| @@ -1,15 +1,72 @@ | |||
| <% stars = product.stars %> | |||
| <% reviews_count = product.reviews_count %> | |||
| <% @average_rating = product.reviews.count > 0 ? product.reviews.sum(:rating).to_f / product.reviews.count : 0 %> | |||
| <% reviews_count = product.reviews_count %> | ||
| <% @average_rating = product.reviews.count > 0 ? product.reviews.sum(:rating).to_f / product.reviews.count : 0 %> | ||
|
|
||
| <% reviews_count = product.reviews.count %> |
| <% @average_rating = product.reviews.count > 0 ? product.reviews.sum(:rating).to_f / product.reviews.count : 0 %> | ||
|
|
||
| <% reviews_count = product.reviews.count %> | ||
| <% raiting_five = reviews_count != 0 ? product.reviews.raiting_five * 100 / reviews_count : 0 %> |
Author
There was a problem hiding this comment.
make a helper for this
raiting_four = reviews_count != 0 ? product.reviews.raiting_four * 100 / reviews_count
| <div class="d-flex"> | ||
| <p class="ratings-stars product-review-rating-stars"> | ||
| <% if product.reviews.count > 0 %> | ||
| <%= @average_rating.try(:round) %> |
| <% else %> | ||
| 0 | ||
| <% end %> | ||
| <span title="<%= txt_stars(@average_rating) %>"> |
|
|
||
| <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> | ||
| <span itemprop="ratingValue" content="<%= stars %>"></span> | ||
| <span itemprop="ratingValue" content="<%= @average_rating %>"></span> |
added 7 commits
May 21, 2021 21:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.