From bdc07d56e59e51fe67c7ad1b4a21dd996306ad2c Mon Sep 17 00:00:00 2001 From: Jamie McCarthy Date: Wed, 17 Mar 2004 18:18:20 +0000 Subject: [PATCH] Only show top 25 hitcount stories, not all of them with > 100 hits --- plugins/Stats/adminmail.pl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/Stats/adminmail.pl b/plugins/Stats/adminmail.pl index dcad1c1ed..ce0b0c228 100644 --- a/plugins/Stats/adminmail.pl +++ b/plugins/Stats/adminmail.pl @@ -277,6 +277,7 @@ my $late_modders = $stats->getTopModdersNearArchive({limit => 5}); my $early_inactive_modders = $stats->getTopEarlyInactiveDownmodders({limit => 5 }); slashdLog("Problem Modders End"); + foreach my $mod (@$late_modders){ $mod_data{late_modders_report} .= sprintf("%-6d %-20s %5d \n",$mod->{uid}, $mod->{nickname}, $mod->{count}); } @@ -474,7 +475,7 @@ slashdLog("Story Comment Counts Begin"); foreach my $d (@$cc_days) { - my $avg_comments= $stats->getAverageCommentCountPerStoryOnDay($d) || 0; + my $avg_comments = $stats->getAverageCommentCountPerStoryOnDay($d) || 0; $statsSave->createStatDaily("avg_comments_per_story", $avg_comments, { overwrite => 1, day => $d }); @@ -708,19 +709,24 @@ $data{day} = $yesterday ; $data{distinct_comment_posters_uids} = sprintf("%8d", $distinct_comment_posters_uids); - my @lazy; - for my $key (sort - { ($articles->{$b} || 0) <=> ($articles->{$a} || 0) } - keys %$articles - ) { - my $value = $articles->{$key}; - - my $story = $backupdb->getStory($key, ['title', 'uid']); - - push(@lazy, sprintf("%6d %-16s %-30s by %s", - $value, $key, substr($story->{'title'}, 0, 30), - ($slashdb->getUser($story->{uid}, 'nickname') || $story->{uid}) - )) if $story->{'title'} && $story->{uid} && $value > 100; + my @top_articles = + grep { $articles->{$_} >= 100 } + sort { ($articles->{$b} || 0) <=> ($articles->{$a} || 0) } + keys %$articles; + $#top_articles = 24 if $#top_articles > 24; # only list top 25 stories + my @lazy = ( ); + my %nick = ( ); + for my $sid (@top_articles) { + my $hitcount = $articles->{$sid}; + my $story = $backupdb->getStory($sid, [qw( title uid )]); + next unless $story->{title} && $story->{uid}; + $nick{$story->{uid}} ||= $backupdb->getUser($story->{uid}, 'nickname') + || $story->{uid}; + + push @lazy, sprintf( "%6d %-16s %-10s %-30s", + $hitcount, $sid, $nick{$story->{uid}}, + substr($story->{title}, 0, 30), + ); } $mod_data{data} = \%mod_data;