-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Price owl #186
base: master
Are you sure you want to change the base?
Price owl #186
Conversation
self[:avg_rating] = if reviews_count > 0 | ||
reviews.approved.sum(:rating).to_f / reviews_count | ||
reviews.sum(:rating).to_f / reviews.count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert to reviews_count
app/models/spree/review.rb
Outdated
@@ -23,6 +22,15 @@ class Spree::Review < ActiveRecord::Base | |||
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 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line and use 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 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to 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 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use stars
<% else %> | ||
0 | ||
<% end %> | ||
<span title="<%= txt_stars(@average_rating) %>"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use stars
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> | ||
<span itemprop="ratingValue" content="<%= stars %>"></span> | ||
<span itemprop="ratingValue" content="<%= @average_rating %>"></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
No description provided.