Permalink
Browse files

Item38: Changed r497 not to use any external commands at all

git-svn-id: http://svn.foswiki.org/trunk/PageStatsPlugin@517 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
OlivierRaginel OlivierRaginel
OlivierRaginel authored and OlivierRaginel committed Nov 10, 2008
1 parent 1f356b4 commit 33f46c62b8dade3e96b306f3605c450e23bc1911
Showing with 8 additions and 12 deletions.
  1. +8 −12 lib/TWiki/Plugins/PageStatsPlugin.pm
@@ -75,19 +75,15 @@ sub handlePageStats
my $dd = TWiki::Func::getDataDir();
#my @pagestats = `grep $web\\.$topic $dd/log*.txt | grep -E \\(view\\|save\\)`;
use TWiki::Sandbox;
my $sandbox = TWiki::Sandbox->new();
my ($lsresp, $lsexit) = $sandbox->sysCommand("ls -1 $dd");
my @resp = split(/\n/, $lsresp);
my @logs = grep(/log2.*.txt/, @resp);
my $logs = "";
foreach my $l (@logs) {
$logs .= "$dd/$l ";
opendir DATADIR, $dd or die "Can't open DataDir: $!";
my @pagestats = ();
foreach my $l ( grep /log.*.txt/, readdir DATADIR ) {
open( my $logfile, "< $dd/$l" ) or next;
while( <$logfile> ) {
push @pagestats, $_ if /$web\.$topic/ && /view|save/;
}
}
my $pat = "$web.$topic";
my $x = 'grep -e '.$pat.' -e view -e save '.$logs;
my ($grepresp, $grepexit) = $sandbox->sysCommand('grep -e '.$pat.' -e view -e save '.$logs);
my @pagestats = split(/$/, $grepresp);
closedir DATADIR;
my $maxEntries = scalar &TWiki::Func::extractNameValuePair( $attributes, "max" ) || scalar @pagestats;
$maxEntries = scalar @pagestats if $maxEntries > scalar @pagestats;

0 comments on commit 33f46c6

Please sign in to comment.