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->{Locale} = $options{Locale} || '';
|
||||
$self->{WriteDelay} = $options{WriteDelay} || 3600;
|
||||
$self->{TopUrlUser} = $options{TopUrlUser} || 0;
|
||||
|
||||
if ($self->{Lang}) {
|
||||
open(IN, "$self->{Lang}") or die "ERROR: can't open translation file $self->{Lang}, $!\n";
|
||||
while (my $l = <IN>) {
|
||||
|
@ -569,16 +571,22 @@ sub _parseData
|
|||
my ($self, $time, $elapsed, $client, $code, $bytes, $url, $id, $type) = @_;
|
||||
|
||||
# Get the current year and month
|
||||
my ($sec,$min,$hour,$wday,$yday,$isdst) = '';
|
||||
($sec,$min,$hour,$self->{last_day},$self->{last_month},$self->{last_year},$wday,$yday,$isdst) = localtime($time);
|
||||
$self->{last_year} += 1900;
|
||||
$self->{last_month}++;
|
||||
$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);
|
||||
my ($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime($time);
|
||||
$year += 1900;
|
||||
$month = sprintf("%02d", $month + 1);
|
||||
$day = sprintf("%02d", $day);
|
||||
|
||||
# Set the year/month value for history check
|
||||
my $date = "$self->{last_year}$self->{last_month}$self->{last_day}";
|
||||
# Store data when day change to save history
|
||||
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
|
||||
my $dest = $url;
|
||||
|
@ -610,18 +618,23 @@ sub _parseData
|
|||
|
||||
# Store data when hour change to save memory
|
||||
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
|
||||
$self->_save_data("$1", "$2", "$3");
|
||||
$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();
|
||||
}
|
||||
|
||||
# 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_month} ||= $self->{last_month};
|
||||
|
||||
$self->{tmp_saving} = $time;
|
||||
$self->{tmp_saving} = $time if (!$self->{tmp_saving});
|
||||
|
||||
#### Store client statistics
|
||||
$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:
|
||||
.\" ========================================================================
|
||||
|
@ -38,6 +38,8 @@
|
|||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
. ds C`
|
||||
. ds C'
|
||||
'br\}
|
||||
.\"
|
||||
.\" 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
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
.\"
|
||||
.\" Avoid warning from groff about undefined register 'F'.
|
||||
.de IX
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
.nr rF 0
|
||||
.if \n(.g .if rF .nr rF 1
|
||||
.if (\n(rF:(\n(.g==0)) \{
|
||||
. if \nF \{
|
||||
. 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).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
|
@ -124,7 +133,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.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
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
|
Loading…
Reference in New Issue