From b60662954d47531041b06ae7415e2cc38d380c03 Mon Sep 17 00:00:00 2001 From: Sergio Gonzalez Date: Tue, 26 Apr 2016 18:06:26 +0200 Subject: [PATCH] LPS-65309 Round the number. If there is one blog entry that was rated in 6.2.x with 4 stars, that will have a normalized value of 0.8 in Liferay 7.0. With the current logic, when it casts 0.8 to int it will cast it to 0. Therefore, it will say that there are 0 positive votes and 1 negative vote, while it should be 1 positive vote (3 or more stars) and 0 negative votes. The other issue is that if you rate something with 1 stars out of 5, with thumbs it should be negative thumb but it was marked as positive because the check was done based on if it's bigger than 0 or equals to 0 but we should check with smaller or bigger than 0.5 --- .../docroot/html/taglib/ui/ratings/page.jsp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/portal-web/docroot/html/taglib/ui/ratings/page.jsp b/portal-web/docroot/html/taglib/ui/ratings/page.jsp index 0c95f82399a8dc..34b42d8dac1f21 100644 --- a/portal-web/docroot/html/taglib/ui/ratings/page.jsp +++ b/portal-web/docroot/html/taglib/ui/ratings/page.jsp @@ -140,23 +140,23 @@ if (ratingsEntry != null) { <% - int positiveVotes = (int)ratingsStats.getTotalScore(); + int positiveVotes = (int)Math.round(ratingsStats.getTotalScore()); int negativeVotes = ratingsStats.getTotalEntries() - positiveVotes; %> - " title=""><%= positiveVotes %> + " title=""><%= positiveVotes %> - " title=""><%= negativeVotes %> + " title=""><%= negativeVotes %> - " href="javascript:;"><%= positiveVotes %> + " href="javascript:;"><%= positiveVotes %> - " href="javascript:;"><%= negativeVotes %> + " href="javascript:;"><%= negativeVotes %>
@@ -167,10 +167,10 @@ if (ratingsEntry != null) { String positiveRatingMessage = null; if (type.equals(RatingsType.THUMBS.getValue())) { - positiveRatingMessage = (yourScore > 0) ? "you-have-rated-this-as-good" : "rate-this-as-good"; + positiveRatingMessage = (yourScore >= 0.5) ? "you-have-rated-this-as-good" : "rate-this-as-good"; } else { - positiveRatingMessage = (yourScore > 0) ? "unlike-this" : "like-this"; + positiveRatingMessage = (yourScore >= 0.5) ? "unlike-this" : "like-this"; } %> @@ -184,7 +184,7 @@ if (ratingsEntry != null) { ratingId = PortalUtil.generateRandomKey(request, "taglib_ui_ratings_page_rating"); %> - +