Support UNIQUE_TOTAL count, counting each IP once.
This commit is contained in:
parent
e574258868
commit
3c7779dbf1
2 changed files with 18 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/perl
|
||||
# Copyright (C) 2011, Bradley M. Kuhn
|
||||
# Copyright (C) 2011, 2014 Bradley M. Kuhn
|
||||
#
|
||||
# This program gives you software freedom; you can copy, modify, convey,
|
||||
# and/or redistribute it under the terms of the GNU General Public License
|
||||
|
@ -31,15 +31,19 @@ while (<>) {
|
|||
$url =~ s/\s*\.(ogg|mp3)\s*$/.audio/i; # Treat ogg and mp3 downloads same.
|
||||
$url =~ s/\s*\/$$//; # Always remove trailing slash
|
||||
|
||||
$data{$url}{$ip} = 0 unless defined $data{$url}{$ip};
|
||||
$data{$url}{__TOTAL__} = 0 unless defined $data{$url}{__TOTAL__};
|
||||
$data{$url}{$ip}++;
|
||||
$data{$url}{__TOTAL__}++;
|
||||
|
||||
$data{$url}{__UNIQUE_TOTAL__} = 0 unless defined $data{$url}{__UNIQUE_TOTAL__};
|
||||
$data{$url}{__UNIQUE_TOTAL__}++ if not defined $data{$url}{$ip};
|
||||
|
||||
$data{$url}{$ip} = 0 unless defined $data{$url}{$ip};
|
||||
$data{$url}{$ip}++;
|
||||
}
|
||||
|
||||
foreach my $url (sort { $data{$b}{__TOTAL__} <=> $data{$a}{__TOTAL__}}
|
||||
foreach my $url (sort { $data{$b}{__UNIQUE_TOTAL__} <=> $data{$a}{__UNIQUE_TOTAL__}}
|
||||
keys %data) {
|
||||
print "$url: $data{$url}{__TOTAL__}\n";
|
||||
print "$url: $data{$url}{__UNIQUE_TOTAL__}\n";
|
||||
}
|
||||
###############################################################################
|
||||
# Local variables:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/perl
|
||||
# Copyright (C) 2011, Bradley M. Kuhn
|
||||
# Copyright (C) 2011, 2014, Bradley M. Kuhn
|
||||
#
|
||||
# This program gives you software freedom; you can copy, modify, convey,
|
||||
# and/or redistribute it under the terms of the GNU General Public License
|
||||
|
@ -31,15 +31,19 @@ while (<>) {
|
|||
$url =~ s/\s*\.(ogg|mp3)\s*$/.audio/i; # Treat ogg and mp3 downloads same.
|
||||
$url =~ s/\s*\/$$//; # Always remove trailing slash
|
||||
|
||||
$data{$url}{$ip} = 0 unless defined $data{$url}{$ip};
|
||||
$data{$url}{__TOTAL__} = 0 unless defined $data{$url}{__TOTAL__};
|
||||
$data{$url}{$ip}++;
|
||||
$data{$url}{__TOTAL__}++;
|
||||
|
||||
$data{$url}{__UNIQUE_TOTAL__} = 0 unless defined $data{$url}{__UNIQUE_TOTAL__};
|
||||
$data{$url}{__UNIQUE_TOTAL__}++ if not defined $data{$url}{$ip};
|
||||
|
||||
$data{$url}{$ip} = 0 unless defined $data{$url}{$ip};
|
||||
$data{$url}{$ip}++;
|
||||
}
|
||||
|
||||
foreach my $url (sort { $data{$b}{__TOTAL__} <=> $data{$a}{__TOTAL__}}
|
||||
foreach my $url (sort { $data{$b}{__UNIQUE_TOTAL__} <=> $data{$a}{__UNIQUE_TOTAL__}}
|
||||
keys %data) {
|
||||
print "$url: $data{$url}{__TOTAL__}\n";
|
||||
print "$url: $data{$url}{__UNIQUE_TOTAL__}\n";
|
||||
}
|
||||
###############################################################################
|
||||
# Local variables:
|
||||
|
|
Loading…
Add table
Reference in a new issue