Fixed Rating average has a ridiculous number of significant figures...

Liam W

in memoriam 1998-2020
And Google is using all of them:

Screen Shot 2014-12-03 at 22.52.10.webp
Really, I don't think it should go above 2 sig fig... Although three may be deemed acceptable.

Liam
 
XenResource_ControllerPublic_Author::actionView()'s $viewParams array contains this line:
PHP:
    'ratingAvg' => $resourceModel->getRatingAverage(
        $aggregate['rating_sum'], $aggregate['rating_count']
    ),

XenResource_Model_Resource::prepareResource() should contains this line:
PHP:
$resource['rating'] = $this->getRatingAverage($resource['rating_sum'], $resource['rating_count']);

Both do not enable rounding, which is the 3rd parameter to getRatingAverage() (defaults to false).
 
There was a third occurrence of the rating average not rounding, also, that I've fixed. Arguably we could have defaulted that method to round by default, but we'll avoid that in case anyone has extended or used that method in add-ons.

Fixed thanks :)
 
Back
Top Bottom