Skip to content
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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Price owl #186

wants to merge 15 commits into from

Conversation

om-ma
Copy link

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

No description provided.

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

@@ -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 }
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.

None yet

1 participant