Changeset 2324 for trunk/include


Ignore:
Timestamp:
May 1, 2008, 3:12:34 AM (16 years ago)
Author:
rvelices
Message:
  • move #categories.date_last and nb_images to #user_cache_categories
Location:
trunk/include
Files:
2 edited

Legend:

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

    r2299 r2324  
    4949  if ($filter['enabled'])
    5050  {
    51     $upd_fields = array('max_date_last', 'count_images', 'count_categories', 'nb_images');
     51    $upd_fields = array('date_last', 'max_date_last', 'count_images', 'count_categories', 'nb_images');
    5252
    5353    foreach ($cats as $cat_id => $category)
  • trunk/include/functions_user.inc.php

    r2313 r2324  
    583583function get_computed_categories($userdata, $filter_days=null)
    584584{
    585   $group_by = '';
    586 
    587585  $query = 'SELECT c.id cat_id, global_rank';
    588586  // Count by date_available to avoid count null
    589587  $query .= ',
    590   MAX(date_available) cat_date_last,  COUNT(date_available) cat_nb_images
     588  MAX(date_available) date_last, COUNT(date_available) nb_images
    591589FROM '.CATEGORIES_TABLE.' as c
    592590  LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
     
    599597    $query .= ' AND i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$filter_days.' DAY)';
    600598  }
    601   $group_by = 'c.id';
    602599
    603600  if ( !empty($userdata['forbidden_categories']) )
     
    607604  }
    608605
    609   if ( !empty($group_by) )
    610   {
    611     $query.= '
    612   GROUP BY '.$group_by;
    613   }
     606  $query.= '
     607  GROUP BY c.id';
    614608
    615609  $result = pwg_query($query);
     
    620614    $row['user_id'] = $userdata['id'];
    621615    $row['count_categories'] = 0;
    622     $row['count_images'] = $row['cat_nb_images'];
    623     $row['max_date_last'] = $row['cat_date_last'];
     616    $row['count_images'] = (int)$row['nb_images'];
     617    $row['max_date_last'] = $row['date_last'];
    624618
    625619    $cats += array($row['cat_id'] => $row);
     
    640634        // Re-init counters
    641635        $category['count_categories'] = 0;
    642         $category['count_images'] = $category['cat_nb_images'];
    643         // next line for update_cats_with_filtered_data
    644         $category['nb_images'] = $category['cat_nb_images'];
     636        $category['count_images'] = (int)$category['nb_images'];
    645637        // Keep category
    646638        $cats[$category['cat_id']] = $category;
     
    677669    (
    678670      'user_id', 'cat_id',
    679       'max_date_last', 'count_images', 'count_categories'
     671      'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories'
    680672    ),
    681673    $cats
Note: See TracChangeset for help on using the changeset viewer.