Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup (take SQL out of .pl file)
  • Loading branch information
jamiemccarthy committed Dec 19, 2004
1 parent d3dae27 commit 0f89fde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 11 additions & 0 deletions plugins/Stats/Stats.pm
Expand Up @@ -1090,6 +1090,17 @@ sub countDailySubscribers {
return $count;
}

########################################################
sub getStat {
my($self, $name, $day, $skid) = @_;
$skid ||= 0;
my $name_q = $self->sqlQuote($name);
my $day_q = $self->sqlQuote($day);
my $skid_q = $self->sqlQuote($skid);
return $self->sqlSelect("value", "stats_daily",
"name=$name_q AND day=$day_q AND skid=$skid_q");
}

########################################################
sub getStatToday {
my($self, $name) = @_;
Expand Down
5 changes: 2 additions & 3 deletions plugins/Stats/adminmail.pl
Expand Up @@ -518,8 +518,7 @@
}

foreach my $day (@ah_days){
my $avg = $stats->sqlSelect("value", "stats_daily",
"day='$day' AND skid='0' AND name='avg_comments_per_story'");
my $avg = $stats->getStat("avg_comments_per_story", $day, 0);
push @{$data{avg_comments_per_story}}, sprintf("%12.1f", $avg);
}
slashdLog("Story Comment Counts End");
Expand Down Expand Up @@ -679,7 +678,7 @@
}

foreach my $day (@ah_days){
my $avg = $stats->sqlSelect("value", "stats_daily", "day='$day' and skid='0' and name='avg_hits_per_story'");
my $avg = $stats->getStat("avg_hits_per_story", $day, 0);
push @{$data{avg_hits_per_story}}, sprintf("%12.1f", $avg);
}

Expand Down

0 comments on commit 0f89fde

Please sign in to comment.