Fix bug in last/first hour of a day data storage that mixed collected data over the two days and stored false first and last visit time.
This commit is contained in:
parent
c3ce63eed8
commit
0db63c377a
|
@ -420,6 +420,8 @@ sub _init
|
||||||
$self->{ImgFormat} = $options{ImgFormat} || 'png';
|
$self->{ImgFormat} = $options{ImgFormat} || 'png';
|
||||||
$self->{Locale} = $options{Locale} || '';
|
$self->{Locale} = $options{Locale} || '';
|
||||||
$self->{WriteDelay} = $options{WriteDelay} || 3600;
|
$self->{WriteDelay} = $options{WriteDelay} || 3600;
|
||||||
|
$self->{TopUrlUser} = $options{TopUrlUser} || 0;
|
||||||
|
|
||||||
if ($self->{Lang}) {
|
if ($self->{Lang}) {
|
||||||
open(IN, "$self->{Lang}") or die "ERROR: can't open translation file $self->{Lang}, $!\n";
|
open(IN, "$self->{Lang}") or die "ERROR: can't open translation file $self->{Lang}, $!\n";
|
||||||
while (my $l = <IN>) {
|
while (my $l = <IN>) {
|
||||||
|
@ -569,16 +571,22 @@ sub _parseData
|
||||||
my ($self, $time, $elapsed, $client, $code, $bytes, $url, $id, $type) = @_;
|
my ($self, $time, $elapsed, $client, $code, $bytes, $url, $id, $type) = @_;
|
||||||
|
|
||||||
# Get the current year and month
|
# Get the current year and month
|
||||||
my ($sec,$min,$hour,$wday,$yday,$isdst) = '';
|
my ($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime($time);
|
||||||
($sec,$min,$hour,$self->{last_day},$self->{last_month},$self->{last_year},$wday,$yday,$isdst) = localtime($time);
|
$year += 1900;
|
||||||
$self->{last_year} += 1900;
|
$month = sprintf("%02d", $month + 1);
|
||||||
$self->{last_month}++;
|
$day = sprintf("%02d", $day);
|
||||||
$self->{last_month} = "0$self->{last_month}" if ($self->{last_month} < 10);
|
|
||||||
$self->{last_day} = "0$self->{last_day}" if ($self->{last_day} < 10);
|
|
||||||
$hour = "0$hour" if ($hour < 10);
|
|
||||||
|
|
||||||
# Set the year/month value for history check
|
# Store data when day change to save history
|
||||||
my $date = "$self->{last_year}$self->{last_month}$self->{last_day}";
|
if ($self->{last_year}) {
|
||||||
|
if ("$year$month$day" ne "$self->{last_year}$self->{last_month}$self->{last_day}") {
|
||||||
|
$self->{tmp_saving} = $time;
|
||||||
|
# If the day has changed then we want to save stats of the previous one
|
||||||
|
$self->_save_data($self->{last_year}, $self->{last_month}, $self->{last_day});
|
||||||
|
# Stats can be cleared
|
||||||
|
print STDERR "Clearing statistics storage hashes.\n" if (!$self->{QuietMode});
|
||||||
|
$self->_clear_stats();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Extract the domainname part of the URL
|
# Extract the domainname part of the URL
|
||||||
my $dest = $url;
|
my $dest = $url;
|
||||||
|
@ -610,18 +618,23 @@ sub _parseData
|
||||||
|
|
||||||
# Store data when hour change to save memory
|
# Store data when hour change to save memory
|
||||||
if ($self->{tmp_saving} && ($time > ($self->{tmp_saving} + $self->{WriteDelay})) ) {
|
if ($self->{tmp_saving} && ($time > ($self->{tmp_saving} + $self->{WriteDelay})) ) {
|
||||||
$date =~ /^(\d{4})(\d{2})(\d{2})$/;
|
$self->{tmp_saving} = $time;
|
||||||
# If the day has changed then we want to save stats of the previous one
|
# If the day has changed then we want to save stats of the previous one
|
||||||
$self->_save_data("$1", "$2", "$3");
|
$self->_save_data($self->{last_year}, $self->{last_month}, $self->{last_day});
|
||||||
# Stats can be cleared
|
# Stats can be cleared
|
||||||
print STDERR "Clearing statistics storage hashes.\n" if (!$self->{QuietMode});
|
print STDERR "Clearing statistics storage hashes.\n" if (!$self->{QuietMode});
|
||||||
$self->_clear_stats();
|
$self->_clear_stats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stores last parsed date part
|
||||||
|
$self->{last_year} = $year;
|
||||||
|
$self->{last_month} = $month;
|
||||||
|
$self->{last_day} = $day;
|
||||||
|
$hour = sprintf("%02d", $hour);
|
||||||
|
# Stores first parsed date part
|
||||||
$self->{first_year} ||= $self->{last_year};
|
$self->{first_year} ||= $self->{last_year};
|
||||||
$self->{first_month} ||= $self->{last_month};
|
$self->{first_month} ||= $self->{last_month};
|
||||||
|
$self->{tmp_saving} = $time if (!$self->{tmp_saving});
|
||||||
$self->{tmp_saving} = $time;
|
|
||||||
|
|
||||||
#### Store client statistics
|
#### Store client statistics
|
||||||
$self->{stat_user_hour}{$id}{$hour}{hits}++;
|
$self->{stat_user_hour}{$id}{$hour}{hits}++;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
|
.\" Automatically generated by Pod::Man 2.26 (Pod::Simple 3.07)
|
||||||
.\"
|
.\"
|
||||||
.\" Standard preamble:
|
.\" Standard preamble:
|
||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
|
@ -38,6 +38,8 @@
|
||||||
. ds PI \(*p
|
. ds PI \(*p
|
||||||
. ds L" ``
|
. ds L" ``
|
||||||
. ds R" ''
|
. ds R" ''
|
||||||
|
. ds C`
|
||||||
|
. ds C'
|
||||||
'br\}
|
'br\}
|
||||||
.\"
|
.\"
|
||||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||||
|
@ -48,17 +50,24 @@
|
||||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||||
.\" output yourself in some meaningful fashion.
|
.\" output yourself in some meaningful fashion.
|
||||||
.ie \nF \{\
|
.\"
|
||||||
. de IX
|
.\" Avoid warning from groff about undefined register 'F'.
|
||||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
.de IX
|
||||||
..
|
..
|
||||||
. nr % 0
|
.nr rF 0
|
||||||
. rr F
|
.if \n(.g .if rF .nr rF 1
|
||||||
.\}
|
.if (\n(rF:(\n(.g==0)) \{
|
||||||
.el \{\
|
. if \nF \{
|
||||||
. de IX
|
. de IX
|
||||||
|
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||||
..
|
..
|
||||||
|
. if !\nF==2 \{
|
||||||
|
. nr % 0
|
||||||
|
. nr F 2
|
||||||
|
. \}
|
||||||
|
. \}
|
||||||
.\}
|
.\}
|
||||||
|
.rr rF
|
||||||
.\"
|
.\"
|
||||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||||
|
@ -124,7 +133,7 @@
|
||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "SQUIDANALYZER 1"
|
.IX Title "SQUIDANALYZER 1"
|
||||||
.TH SQUIDANALYZER 1 "2013-05-26" "perl v5.14.2" "User Contributed Perl Documentation"
|
.TH SQUIDANALYZER 1 "2013-05-27" "perl v5.10.1" "User Contributed Perl Documentation"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
|
|
Loading…
Reference in New Issue