Update of /cvsroot/sitesampler/sitesampler/SiteSampler
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6252/SiteSampler
Modified Files:
Agent.pm Report.pm
Log Message:
this is a big commit related to fixing the report object
Index: Report.pm
===================================================================
RCS file: /cvsroot/sitesampler/sitesampler/SiteSampler/Report.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Report.pm 6 Jul 2005 12:24:32 -0000 1.4
--- Report.pm 18 Jul 2005 01:36:38 -0000 1.5
***************
*** 55,58 ****
--- 55,64 ----
}
+ sub cache_html_path{
+ my $self = shift;
+ return $self->cache_file_path."_html";
+ }
+
+
sub latest_date_key{'n_latest_date'}
***************
*** 136,149 ****
my $viewer = SiteSampler::Report::Viewer->new;
my $html_arr = $viewer->html_report($self);
! $self->report_html("@$html_arr");
}
sub report_html{
my $self = shift;
! my $html = $self->get_set('s_report_html',@_)
! || qq|This report has not been updated since it was created. The update will happen within the next 24 hours.|;
return($html);
}
sub analyze_log_data{
my $self = shift;
--- 142,173 ----
my $viewer = SiteSampler::Report::Viewer->new;
my $html_arr = $viewer->html_report($self);
! Storable::store($html_arr,$self->cache_html_path);
! chmod(0777,$self->cache_html_path);
}
sub report_html{
my $self = shift;
! my $html = qq|This report has not been updated since it was created. The update will happen within the next 24 hours.|;
! if(-e $self->cache_html_path){
! $html = Storable::retrieve($self->cache_html_path);
! $html = "@$html";
! }
return($html);
}
+ sub user_id_idx{
+ my $self = shift;
+ my($user_id) = @_;
+
+ my $key = 'user_ids';
+ $self->{$key} = {} unless(exists $self->{$key});
+
+ unless(exists $self->{$key}->{$user_id}){
+ $self->{$key}->{$user_id} = scalar(keys %{$self->{$key}}) + 1;
+ }
+
+ return $self->{$key}->{$user_id};
+ }
+
sub analyze_log_data{
my $self = shift;
***************
*** 163,167 ****
$self->monitors->analyze($log_entry);
$self->os->analyze($log_entry);
! # $self->profiles->analyze($log_entry);
$self->users->analyze($log_entry);
$self->urls->analyze($log_entry);
--- 187,191 ----
$self->monitors->analyze($log_entry);
$self->os->analyze($log_entry);
! $self->profiles->analyze($log_entry);
$self->users->analyze($log_entry);
$self->urls->analyze($log_entry);
Index: Agent.pm
===================================================================
RCS file: /cvsroot/sitesampler/sitesampler/SiteSampler/Agent.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Agent.pm 6 Jul 2005 12:24:32 -0000 1.6
--- Agent.pm 18 Jul 2005 01:36:38 -0000 1.7
***************
*** 78,86 ****
--- 78,119 ----
}
+ sub process_forked{
+ my $self = shift;
+ return $self->get_set('process_forked',@_);
+ }
+
sub process_log{
my $self = shift;
+ if($self->process_forked){
+ $self->_process_log_forked;
+ }else{
+ $self->_process_log;
+ }
+ }
+
+ sub _process_log{
+ my $time = time;
+ my $self = shift;
$self->load_log($self->temp_log_fh);
$self->archive_log;
$self->unlock_log;
+ $time = time - $time;
+ print "done in $time seconds\n";
+ }
+
+ sub _process_log_forked{
+ my $self = shift;
+ my $pid = fork;
+ if($pid){
+ # in the parent
+ wait;
+ die($?) if($?);
+ }elsif(defined($pid)){
+ print "My PID: $$\n";
+ $self->_process_log;
+ exit(0);
+ }else{
+ die("fork failed : $!");
+ }
}
***************
*** 117,120 ****
--- 150,154 ----
$report->cache;
$report->set_report_html;
+ # print $report->report_html;
$report->save;
}
|