Just going by number of moods isn't enough, because duplicated moods 
are counted twice. So we need to count the number of aggregated moods.

        Patch by fu. 

diffs (23 lines):

diff -r e1529b5ec542 -r 0acbf04e2b68 cgi-bin/DW/Controller/Latest/Mood.pm
--- a/cgi-bin/DW/Controller/Latest/Mood.pm      Thu Aug 19 17:32:31 2010 +0800
+++ b/cgi-bin/DW/Controller/Latest/Mood.pm      Thu Aug 19 17:53:28 2010 +0800
@@ -50,7 +50,6 @@ sub mood_handler {
     if ( $count ) {
         my %counts;
         my $score = 0;
-        my $to_show = $count > $num_top ? $num_top : $count;
 
         my $metadata = DW::Mood->get_moods;
 
@@ -59,7 +58,10 @@ sub mood_handler {
             $counts{$metadata->{$moodid}->{name}}++;
         }
 
-        my @names = sort { $counts{$b} <=> $counts{$a} || $a cmp $b } keys 
%counts;
+        my @counts_keys = keys %counts;
+        my $to_show = scalar @counts_keys > $num_top ? $num_top : scalar 
@counts_keys;
+
+        my @names = sort { $counts{$b} <=> $counts{$a} || $a cmp $b } 
@counts_keys;
         my @highest = @names[0..( $to_show - 1)];
         my %top_counts = map { ($_,$counts{$_}) } @highest;
         my @top_mood;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to