Ignore:
Timestamp:
01/21/14 23:50:59 (6 years ago)
Author:
rvelices
Message:

merge -r26900 from trunk to 2.6
admin rating user improvements

  • add last rate date for user
  • add consensus deviation but only based on the best rated photos (e.g. how much this user tries to change the best rated photos)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/admin/rating_user.php

    r26461 r26901  
    3636} 
    3737 
     38$consensus_top_number = $conf['top_number']; 
     39if (isset($_GET['consensus_top_number'])) 
     40{ 
     41  $consensus_top_number = (int)$_GET['consensus_top_number']; 
     42} 
     43 
    3844// build users 
    3945global $conf; 
     
    6167} 
    6268 
    63  
     69// by user aggregation 
    6470$image_ids = array(); 
    6571$by_user_ratings = array(); 
     
    8894    $rating['uid'] = (int)$row['user_id']; 
    8995    $rating['aid'] = $usr['anon'] ? $row['anonymous_id'] : ''; 
     96    $rating['last_date'] = $row['date']; 
    9097  } 
    9198  $rating['rates'][$row['rate']][] = array( 
     
    114121} 
    115122 
     123//all image averages 
    116124$query='SELECT element_id, 
    117125    AVG(rate) AS avg 
     
    125133} 
    126134 
     135$query='SELECT id 
     136  FROM '.IMAGES_TABLE.' 
     137  ORDER by rating_score DESC 
     138  LIMIT '.$consensus_top_number; 
     139$best_rated = array_flip( array_from_query($query, 'id')); 
     140 
     141// by user stats 
    127142foreach($by_user_ratings as $id => &$rating) 
    128143{ 
    129   $c=0; $s=0; $ss=0; $consensus_dev=0; 
     144  $c=0; $s=0; $ss=0; $consensus_dev=0; $consensus_dev_top=0; $consensus_dev_top_count=0; 
    130145  foreach($rating['rates'] as $rate => $rates) 
    131146  { 
     
    136151    foreach($rates as $id_date) 
    137152    { 
    138       $consensus_dev += abs($rate - $all_img_sum[$id_date['id']]['avg']); 
     153      $dev = abs($rate - $all_img_sum[$id_date['id']]['avg']); 
     154      $consensus_dev += $dev; 
     155      if (isset($best_rated[$id_date['id']])) 
     156      { 
     157        $consensus_dev_top += $dev; 
     158        $consensus_dev_top_count++; 
     159      } 
    139160    } 
    140161  } 
    141162 
    142163  $consensus_dev /= $c; 
     164  if ($consensus_dev_top_count) 
     165    $consensus_dev_top /= $consensus_dev_top_count; 
    143166 
    144167  $var = ($ss - $s*$s/$c)/$c; 
     
    148171    'avg' => $s/$c, 
    149172    'cv'  => $s==0 ? -1 : sqrt($var)/($s/$c), // http://en.wikipedia.org/wiki/Coefficient_of_variation 
    150     'cd'  => $consensus_dev 
     173    'cd'  => $consensus_dev, 
     174    'cdtop'  => $consensus_dev_top_count ? $consensus_dev_top : '' 
    151175  ); 
    152176} 
     
    214238  'F_ACTION' => get_root_url().'admin.php', 
    215239  'F_MIN_RATES' => $filter_min_rates, 
     240  'CONSENSUS_TOP_NUMBER' => $consensus_top_number, 
    216241  'available_rates' => $conf['rate_items'], 
    217242  'ratings' => $by_user_ratings, 
Note: See TracChangeset for help on using the changeset viewer.