diff options
author | rvelices <rv-github@modusoptimus.com> | 2011-07-25 18:04:50 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2011-07-25 18:04:50 +0000 |
commit | 4e4dc79e5162a7d1315b12e94153443552530b9e (patch) | |
tree | feec6972f3ff9eb108ce87fe672414b98da69a85 /admin/include | |
parent | 86bc4d1143474dcb5b9a65c1affd62d7e1b14c0c (diff) |
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
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index cd03a662e..2c9c9df39 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1051,67 +1051,6 @@ UPDATE '.IMAGES_TABLE.' } /** - * update images.average_rate field - * param int $element_id optional, otherwise applies to all - * @return void - */ -function update_average_rate( $element_id=-1 ) -{ - $query = ' -SELECT element_id, - ROUND(AVG(rate),2) AS average_rate - FROM '.RATE_TABLE; - if ( $element_id != -1 ) - { - $query .= ' WHERE element_id=' . $element_id; - } - $query .= ' GROUP BY element_id;'; - - $result = pwg_query($query); - - $datas = array(); - - while ($row = pwg_db_fetch_assoc($result)) - { - array_push( - $datas, - array( - 'id' => $row['element_id'], - 'average_rate' => $row['average_rate'] - ) - ); - } - - mass_updates( - IMAGES_TABLE, - array( - 'primary' => array('id'), - 'update' => array('average_rate') - ), - $datas - ); - - $query=' -SELECT id FROM '.IMAGES_TABLE .' - LEFT JOIN '.RATE_TABLE.' ON id=element_id - WHERE element_id IS NULL AND average_rate IS NOT NULL'; - if ( $element_id != -1 ) - { - $query .= ' AND id=' . $element_id; - } - $to_update = array_from_query( $query, 'id'); - - if ( !empty($to_update) ) - { - $query=' -UPDATE '.IMAGES_TABLE .' - SET average_rate=NULL - WHERE id IN (' . implode(',',$to_update) . ')'; - pwg_query($query); - } -} - -/** * change the parent category of the given categories. The categories are * supposed virtual. * |