From 84e2c7f25e638ebb094218e925cd23c39ce74fc5 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 25 Aug 2021 22:09:06 +0100 Subject: [PATCH] Fix review score logic (#67) Was incorrectly adding 1 to review count, which was reducing the overall review score --- models/Reviews_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/Reviews_model.php b/models/Reviews_model.php index 5f5576a..dae6b38 100644 --- a/models/Reviews_model.php +++ b/models/Reviews_model.php @@ -211,6 +211,6 @@ public static function getScoreForLocation($locationId) $totalReviews += $totalRatings; } - return $totalWeight / ($totalReviews + 1); + return $totalReviews > 0 ? ($totalWeight / $totalReviews) : 0; } }