Update of /cvsroot/sitesampler/sitesampler/SiteSampler/Report
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17312/SiteSampler/Report
Modified Files:
Base.pm Urls.pm Viewer.pm
Log Message:
committing what is very close to another rendition of the web stats report
Index: Viewer.pm
===================================================================
RCS file: /cvsroot/sitesampler/sitesampler/SiteSampler/Report/Viewer.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Viewer.pm 28 Aug 2005 18:46:59 -0000 1.6
--- Viewer.pm 31 Aug 2005 01:59:44 -0000 1.7
***************
*** 56,63 ****
$self->report_section('daysofweek',$report->hits->weekdays,'Days of Week','Weekday');
$self->report_section('hoursofday',$report->hits->hourly,'Hourly','Hour of Day');
! $self->report_section('urls',$report->urls,'Requested Pages','URL');
# $self->report_section('internal_referers',$report->referers->internal);
$self->report_section('direct_referers',$report->referers->direct,'Referring Pages - Direct','URL');
! $self->report_section('search_referers',$report->referers->search_engine,'Referring Pages - Search Engine','');
$self->report_section('solicitations',$report->solicitations,'Points of Solicitation','URL');
--- 56,63 ----
$self->report_section('daysofweek',$report->hits->weekdays,'Days of Week','Weekday');
$self->report_section('hoursofday',$report->hits->hourly,'Hourly','Hour of Day');
! $self->url_report_section('urls',$report->urls,'Requested Pages');
# $self->report_section('internal_referers',$report->referers->internal);
$self->report_section('direct_referers',$report->referers->direct,'Referring Pages - Direct','URL');
! $self->report_section('search_referers',$report->referers->search_engine,'Referring Pages - Search Engine','URL');
$self->report_section('solicitations',$report->solicitations,'Points of Solicitation','URL');
***************
*** 95,98 ****
--- 95,106 ----
}
+ sub url_report_section{
+ my $self = shift;
+ my($anchor_label,$obj,$table_heading) = @_;
+ $self->a_name($anchor_label);
+ $self->draw_url_table($obj,$table_heading);
+ $self->section_footer;
+ }
+
sub report_section{
my $self = shift;
***************
*** 105,108 ****
--- 113,132 ----
##### standard stats table ########
+
+ sub draw_url_table{
+ my $self = shift;
+ my($url_obj,$table_heading) = @_;
+ push(@{$self->out},$self->url_table_header($table_heading));
+
+ for my $collection ($url_obj->get_collections){
+ my $template = HTML::Template->new(scalarref => \$self->url_table_template);
+ $template->param($self->url_report_data($collection,$collection->url_root));
+
+ push(@{$self->out},$template->output);
+ }
+
+ push(@{$self->out},$self->url_table_footer);
+ }
+
sub draw_table{
my $self = shift;
***************
*** 115,130 ****
}
sub report_data{
my $self = shift;
my($obj,$table_heading,$table_item_title) = @_;
my $report_data = {};
-
$report_data->{table_heading} = $table_heading;
$report_data->{table_item_title} = $table_item_title;
my @obj_ids = $obj->obj_ids_max_hits;
my $tuu = $obj->report->users->total_unique_users;
my $total_hits = $obj->report->hits->total_hits;
!
my $object_rows = [];
for my $obj_id (@obj_ids){
--- 139,168 ----
}
+ sub url_report_data{
+ my $self = shift;
+ my($obj,$url_root) = @_;
+ my $report_data = {};
+ $report_data->{url_root} = $url_root;
+ $report_data->{OBJECT_ROWS} = _object_rows($obj,1);# pass self as the second param cause this is a private method
+ return($report_data);
+ }
+
sub report_data{
my $self = shift;
my($obj,$table_heading,$table_item_title) = @_;
my $report_data = {};
$report_data->{table_heading} = $table_heading;
$report_data->{table_item_title} = $table_item_title;
+ $report_data->{OBJECT_ROWS} = _object_rows($obj); # pass self as the second param cause this is a private method
+ return($report_data);
+ }
+
+ sub _object_rows{
+ my($obj,$is_url) = @_;
my @obj_ids = $obj->obj_ids_max_hits;
my $tuu = $obj->report->users->total_unique_users;
my $total_hits = $obj->report->hits->total_hits;
!
my $object_rows = [];
for my $obj_id (@obj_ids){
***************
*** 137,153 ****
$obj_data->{percent_unique_users} = sprintf("%.3f",($tuu ? ($obj_data->{unique_users}/$tuu) * 100 : 0));
# we hyperlink the object if it is a url
! $obj_data->{obj_name} = _link_it($obj->name);
push(@$object_rows,$obj_data);
}
! $report_data->{OBJECT_ROWS} = $object_rows;
! return($report_data);
}
sub _link_it{
! my($str) = @_;
! if(_is_uri($str)){
! $str = qq|<a href="$str" target="urlwin">$str</a>|;
}
! return($str);
}
--- 175,196 ----
$obj_data->{percent_unique_users} = sprintf("%.3f",($tuu ? ($obj_data->{unique_users}/$tuu) * 100 : 0));
# we hyperlink the object if it is a url
! $obj_data->{obj_name} = $is_url ? _link_it($obj) : $obj->name;
push(@$object_rows,$obj_data);
}
! return($object_rows);
}
sub _link_it{
! my($qstr_obj) = @_;
! my $url_root = $qstr_obj->parent->url_root;
! my $qstr = $qstr_obj->name;
! my $qstr_display = $qstr;
! if(defined($qstr) && length($qstr) > 0){
! $qstr_display = substr($qstr,0,49) if(length($qstr) > 50);
! $qstr = '?'.$qstr;
}
! my $url = $url_root.$qstr;
! my $link = qq|\n<a href="$url" target="urlwin" title="$url">$qstr_display</a>\n|;
! return($link);
}
***************
*** 160,163 ****
--- 203,251 ----
}
+ sub url_table_header{
+ my $self = shift;
+ my($table_heading) = @_;
+ return(qq|
+ <table class="blank2">
+ <tr>
+ <th>$table_heading</th>
+ <td class="th2" width="15%" bgcolor="#FFB055">Unique Visitors</td>
+ <td class="th2" width="15%" bgcolor="#FFB055">% Unique Visitors</td>
+ <td class="th2" width="15%" bgcolor="#66F0FF">Page Views</td>
+ <td class="th2" width="15%" bgcolor="#66F0FF">% Page Views</td>
+ </tr>
+ |);
+ }
+
+ sub url_table_footer{"\n</table>\n"}
+
+ sub url_table_template{
+ my $self = shift;
+
+ my $template = qq|
+ <tr>
+ <td class="th2" width="100%" bgcolor="#7EACD3" align="left" colspan="5"><TMPL_VAR name=URL_ROOT></td>
+ <!--
+ <td class="th2" width="15%" bgcolor="#FFB055">Unique Visitors</td>
+ <td class="th2" width="15%" bgcolor="#FFB055">% Unique Visitors</td>
+ <td class="th2" width="15%" bgcolor="#66F0FF">Page Views</td>
+ <td class="th2" width="15%" bgcolor="#66F0FF">% Page Views</td>
+ -->
+ </tr>
+
+ <TMPL_LOOP NAME=OBJECT_ROWS>
+ <tr class="th5">
+ <td class="th2" align="left"><TMPL_VAR name=OBJ_NAME></td>
+ <td><TMPL_VAR name=UNIQUE_USERS></td>
+ <td><TMPL_VAR name=PERCENT_UNIQUE_USERS></td>
+ <td><TMPL_VAR name=OBJ_HITS></td>
+ <td><TMPL_VAR name=PERCENT_HITS></td>
+ </tr>
+ </TMPL_LOOP>
+ |;
+ return($template);
+
+ }
+
sub table_template{
my $self = shift;
Index: Base.pm
===================================================================
RCS file: /cvsroot/sitesampler/sitesampler/SiteSampler/Report/Base.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Base.pm 22 Jul 2005 03:42:17 -0000 1.9
--- Base.pm 31 Aug 2005 01:59:44 -0000 1.10
***************
*** 81,85 ****
sub add_obj{
my $self = shift;
! my($obj_id) = @_;
unless(exists $self->{$obj_id}){
--- 81,86 ----
sub add_obj{
my $self = shift;
! my($obj_id) = @_;
! $obj_id = '' unless defined($obj_id);
unless(exists $self->{$obj_id}){
***************
*** 88,92 ****
$self->{$obj_id} = $self->fetch_obj($obj_id)
! or die(qq|cannot fetch object for obj_id: $obj_id|);
}
--- 89,93 ----
$self->{$obj_id} = $self->fetch_obj($obj_id)
! or die(qq|cannot fetch object for obj_id: $obj_id : |.ref($self));
}
***************
*** 109,113 ****
sub obj_ids_max_hits{
my $self = shift;
! return(sort {$self->obj_count_hash->{$b} <=> $self->obj_count_hash->{$a}} keys %{$self->obj_count_hash});
}
--- 110,117 ----
sub obj_ids_max_hits{
my $self = shift;
! return(sort {$self->obj_count_hash->{$b}
! <=> $self->obj_count_hash->{$a}}
! keys %{$self->obj_count_hash}
! );
}
Index: Urls.pm
===================================================================
RCS file: /cvsroot/sitesampler/sitesampler/SiteSampler/Report/Urls.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Urls.pm 28 Aug 2005 18:46:59 -0000 1.6
--- Urls.pm 31 Aug 2005 01:59:44 -0000 1.7
***************
*** 3,7 ****
use Data::Dumper;
use File::Path;
! use SiteSampler::Urls::Collection;
use SiteSampler::Report::Urls::Url;
use SiteSampler::Report::Base;
--- 3,7 ----
use Data::Dumper;
use File::Path;
! use SiteSampler::Report::Urls::Collection;
use SiteSampler::Report::Urls::Url;
use SiteSampler::Report::Base;
***************
*** 51,58 ****
my $self = shift;
my($log_entry) = @_;
my($url_path,$qstr) = split(/\?/,$url,2);
! my $collection = $self->add_collection($log_entry->client_url);
! my $url_obj = $collection->add_obj($qstr);
! $url_obj->add_user($log_entry->user_id);
}
--- 51,59 ----
my $self = shift;
my($log_entry) = @_;
+ my $url = $log_entry->client_url;
my($url_path,$qstr) = split(/\?/,$url,2);
! my $collection = $self->add_collection($url_path);
! my $qstr_obj = $collection->add_obj($qstr);
! $qstr_obj->add_user($log_entry->user_id);
}
***************
*** 62,70 ****
sub add_collection{
my $self = shift;
! my($url_path) = @_;
my($url_path,$qstr) = split(/\?/,$url,2);
unless($self->collection($url_path)){
! $collection_class = ref($self).'::'.$self->collection_class_suffix
! $self->{$url_path} = $collection_class->new($url_path);
}
return $self->collection($url_path);
--- 63,70 ----
sub add_collection{
my $self = shift;
! my($url) = @_;
my($url_path,$qstr) = split(/\?/,$url,2);
unless($self->collection($url_path)){
! $self->obj_count_hash->{$url_path} = SiteSampler::Report::Urls::Collection->new($url_path,$self->report);
}
return $self->collection($url_path);
***************
*** 73,97 ****
sub collection{
my $self = shift;
! my($url_path) = @_;
my $collection;
! if($url_path && exists($self->{$url_path})){
! $collection = $self->{$url_path};
}
return $collection;
}
! sub get_obj{
my $self = shift;
! my($obj_id) = @_;
! my($url,$qstr) = split(/\?/,$obj_id,2);
!
! return(
! (my $collection = $self->collection($url))
! ? $collection->get_obj($qstr);
! : undef
! );
}
! sub obj_count_hash_key{'urls'}
sub base_class_suffix{'Url'}
sub collection_class_suffix{'Collection'};
--- 73,93 ----
sub collection{
my $self = shift;
! my($url) = @_;
! my($url_path,$qstr) = split(/\?/,$url,2);
my $collection;
! if($url_path && exists($self->obj_count_hash->{$url_path})){
! $collection = $self->obj_count_hash->{$url_path};
}
return $collection;
}
! sub get_collections{
my $self = shift;
! return(values %{$self->obj_count_hash});
}
! sub get_obj{ collection(@_); }
!
! sub obj_count_hash_key{'collections'}
sub base_class_suffix{'Url'}
sub collection_class_suffix{'Collection'};
|