Ignore:
Timestamp:
Jul 25, 2011, 8:04:50 PM (13 years ago)
Author:
rvelices
Message:

feature 2384: improve average rating calculation (still need to update language files)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/picture_rate.inc.php

    r8728 r11827  
    2929if ($conf['rate'])
    3030{
    31   if ( NULL != $picture['current']['average_rate'] )
     31  $rate_summary = array( 'count'=>0, 'score'=>$picture['current']['average_rate'], 'average'=>null );
     32  if ( NULL != $rate_summary['score'] )
    3233  {
    3334    $query = '
     
    3738  WHERE element_id = '.$picture['current']['id'].'
    3839;';
    39     $row = pwg_db_fetch_assoc(pwg_query($query));
     40                list($rate_summary['count'], $rate_summary['average']) = pwg_db_fetch_row(pwg_query($query));
    4041  }
    41   else
    42   { // avg rate null -> no rate -> no need to query db
    43     $row = array( 'count'=>0, 'average'=>NULL );
    44   }
    45   $template->assign('rate_summary', $row);
     42  $template->assign('rate_summary', $rate_summary);
    4643
    4744  $user_rate = null;
    4845  if ($conf['rate_anonymous'] or is_autorize_status(ACCESS_CLASSIC) )
    4946  {
    50     if ($row['count']>0)
     47    if ($rate_summary['count']>0)
    5148    {
    5249      $query = 'SELECT rate
Note: See TracChangeset for help on using the changeset viewer.