Changeset 3082 for trunk/lib/MT/CMS/Dashboard.pm
- Timestamp:
- 10/03/08 01:07:01 (14 months ago)
- Files:
-
- 1 modified
-
trunk/lib/MT/CMS/Dashboard.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/MT/CMS/Dashboard.pm
r2812 r3082 404 404 405 405 my $terms = {}; 406 my $args = {}; 406 407 $terms->{blog_id} = $blog_id if $blog_id; 407 408 $terms->{object_datasource} = 'entry'; 408 my $args = {};409 409 $args->{group} = [ 'tag_id' ]; 410 410 $args->{sort} = '1'; # sort by count(*) 411 411 $args->{direction} = 'descend'; 412 412 $args->{limit} = 100; 413 $args->{join} = MT::Tag->join_on(undef, { id => \'= objecttag_tag_id', is_private => 1 }, 414 { not => { is_private => 1 } } ); 413 415 414 416 my $iter = $app->model('objecttag')->count_group_by($terms, $args); 415 417 my @tag_loop; 418 my @tag_ids; 416 419 my $ntags = 0; 417 420 my $min = undef; 418 421 my $max = undef; 419 422 while (my ($count, $tag_id) = $iter->()) { 420 my $tag = MT::Tag->load($tag_id) or next;421 next if $tag->is_private; # weed these from the dashboard422 423 $ntags += $count; 423 424 $min = defined $min ? ($count < $min ? $count : $min) : $count; 424 425 $max = defined $max ? ($count > $max ? $count : $max) : $count; 425 push @tag_loop, { name => $tag->name, count => $count }; 426 push @tag_loop, { id => $tag_id, count => $count }; 427 push @tag_ids, $tag_id; 428 } 429 430 if ( @tag_ids ) { 431 my $iter = MT::Tag->load_iter( { id => \@tag_ids } ); 432 my %tags; 433 while ( my $t = $iter->() ) { 434 $tags{ $t->id } = $t->name; 435 } 436 $_->{name} = $tags{$_->{id}} for @tag_loop; 426 437 } 427 438
