Skip to content

Conversation

om-ma
Copy link

@om-ma om-ma commented May 21, 2021

No description provided.

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert to 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 }
Copy link
Author

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 %>
Copy link
Author

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 %>
Copy link
Author

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 %>
Copy link
Author

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) %>
Copy link
Author

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) %>">
Copy link
Author

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>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant