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/ws_functions.inc.php

    r11756 r11827  
    782782  }
    783783  //------------------------------------------------------------- related rates
    784   $query = '
     784        $rating = array('score'=>$image_row['average_rate'], 'count'=>0, 'average'=>null);
     785        if (isset($rating['score']))
     786        {
     787                $query = '
    785788SELECT COUNT(rate) AS count
    786789     , ROUND(AVG(rate),2) AS average
     
    788791  WHERE element_id = '.$image_row['id'].'
    789792;';
    790   $rating = pwg_db_fetch_assoc(pwg_query($query));
    791   $rating['count'] = (int)$rating['count'];
     793                $row = pwg_db_fetch_assoc(pwg_query($query));
     794                $rating['score'] = (float)$rating['score'];
     795                $rating['average'] = (float)$row['average'];
     796                $rating['count'] = (int)$row['count'];
     797        }
    792798
    793799  //---------------------------------------------------------- related comments
Note: See TracChangeset for help on using the changeset viewer.