Changeset 2324 for trunk/include
- Timestamp:
- May 1, 2008, 3:12:34 AM (16 years ago)
- Location:
- trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_filter.inc.php
r2299 r2324 49 49 if ($filter['enabled']) 50 50 { 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'); 52 52 53 53 foreach ($cats as $cat_id => $category) -
trunk/include/functions_user.inc.php
r2313 r2324 583 583 function get_computed_categories($userdata, $filter_days=null) 584 584 { 585 $group_by = '';586 587 585 $query = 'SELECT c.id cat_id, global_rank'; 588 586 // Count by date_available to avoid count null 589 587 $query .= ', 590 MAX(date_available) cat_date_last, COUNT(date_available) cat_nb_images588 MAX(date_available) date_last, COUNT(date_available) nb_images 591 589 FROM '.CATEGORIES_TABLE.' as c 592 590 LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id … … 599 597 $query .= ' AND i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$filter_days.' DAY)'; 600 598 } 601 $group_by = 'c.id';602 599 603 600 if ( !empty($userdata['forbidden_categories']) ) … … 607 604 } 608 605 609 if ( !empty($group_by) ) 610 { 611 $query.= ' 612 GROUP BY '.$group_by; 613 } 606 $query.= ' 607 GROUP BY c.id'; 614 608 615 609 $result = pwg_query($query); … … 620 614 $row['user_id'] = $userdata['id']; 621 615 $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']; 624 618 625 619 $cats += array($row['cat_id'] => $row); … … 640 634 // Re-init counters 641 635 $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']; 645 637 // Keep category 646 638 $cats[$category['cat_id']] = $category; … … 677 669 ( 678 670 'user_id', 'cat_id', 679 ' max_date_last', 'count_images', 'count_categories'671 'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories' 680 672 ), 681 673 $cats
Note: See TracChangeset
for help on using the changeset viewer.