mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 17:23:04 +02:00
feature 2384: improve average rating calculation (still need to update language files)
git-svn-id: http://piwigo.org/svn/trunk@11827 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -781,14 +781,20 @@ SELECT id, name, permalink, uppercats, global_rank, commentable
|
||||
$related_tags[$i]=$tag;
|
||||
}
|
||||
//------------------------------------------------------------- related rates
|
||||
$query = '
|
||||
$rating = array('score'=>$image_row['average_rate'], 'count'=>0, 'average'=>null);
|
||||
if (isset($rating['score']))
|
||||
{
|
||||
$query = '
|
||||
SELECT COUNT(rate) AS count
|
||||
, ROUND(AVG(rate),2) AS average
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$image_row['id'].'
|
||||
;';
|
||||
$rating = pwg_db_fetch_assoc(pwg_query($query));
|
||||
$rating['count'] = (int)$rating['count'];
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
$rating['score'] = (float)$rating['score'];
|
||||
$rating['average'] = (float)$row['average'];
|
||||
$rating['count'] = (int)$row['count'];
|
||||
}
|
||||
|
||||
//---------------------------------------------------------- related comments
|
||||
$related_comments = array();
|
||||
|
||||
Reference in New Issue
Block a user