Tagged: average calculation
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by BePro Software Team.
-
AuthorPosts
-
June 18, 2015 at 1:22 am #5917JimMember
I have my system setup so comments must be approved manually so they don’t show on the site until they’ve been moderated. But it seems the average rating is including ratings for pending comments. Even worse, it’s including ratings for deleted comments.
Thanks.
June 18, 2015 at 3:13 pm #5928BePro Software TeamKeymasterHi Jim,
Can you double check that it’s calculating deleted comments? Were those comments published? I remember we addressed the delete issue in the past, so want to confirm before alerting our dev team
___
BePro Software TeamJune 18, 2015 at 6:25 pm #5931JimMemberHi,
Yes, I just confirmed. I had put the comment in the trash and the average rating still included it. I just tried emptying the trash and the average is still wrong. Here’s an example:
http://www.boardandcareca.com/board-and-care-homes/compassionate-eldercare-rcfe/#undefined2
There is only 1 rating here of 3 stars, but the average rating shows 5 stars. There are no pending comments and nothing in the trash so it appears the rating record is left orphaned and is still being included in the average.
I don’t have the list of tables in front of me, but I believe the SQL statement for the average rating needs to be changed to join on the comments table where the comment status is approved. The average rating should only include ratings for approved comments.
Thanks,
JimJune 18, 2015 at 10:34 pm #5937BePro Software TeamKeymasterHi,
Thanks for clarifying. Those terminologies really make a difference. Our fix was focused on listings that are deleted, not trashed. As you noted, we do not monitor the status of the comment. If the comment is deleted, then the rating is deleted.
I definitely understand your perspective. If you believe the delete feature doesn’t fit your needs, we can add status monitoring to our development plan. An sql join does sound like a potential fix that the community may appreciate
___
BePro Software TeamJune 19, 2015 at 2:12 pm #5942JimMemberI went ahead and made this trivial fix myself.
File: /wp-content/bepro_listings_reviews/bepro_listings_reviews.php
Line 245 changed to:
return $wpdb->get_row(“SELECT COUNT(post_id) as num_results, SUM(rating) as rating FROM “.BEPRO_LISTINGS_REVIEWS_TABLE.” JOIN wp_comments USING (comment_id) WHERE comment_approved = 1 AND post_id = “.$post_id);Now only approved comments/ratings are included in the average rating. If they are pending, trashed or deleted they are not included.
– Jim
June 20, 2015 at 8:54 am #5944BePro Software TeamKeymasterHi,
Glad to hear you are making progress for your needs.
For us, a fix is never trivial. We have thousands of customers to consider with every change. We must consider the expectations of existing users, with every new individual request. In addition, we have over 20 addons that need to cohesively work together to manage large numbers of listings.
Thanks for sharing your fix. Our development team will evaluate the code and if its accepted, schedule it for inclusion and release.
___
BePro Software Team -
AuthorPosts
- You must be logged in to reply to this topic.