[freeside-commits] branch FREESIDE_4_BRANCH updated. b06cbe907c8b7b655db21ca547b46f9f0241a443

Ivan ivan at 420.am
Tue Feb 9 21:07:58 PST 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  b06cbe907c8b7b655db21ca547b46f9f0241a443 (commit)
      from  4b51d95adb7a3625d462cb60e4cb733749584d0a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b06cbe907c8b7b655db21ca547b46f9f0241a443
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 9 21:07:57 2016 -0800

    log statistics, RT#39822

diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index ee4f174..c385cb4 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -528,6 +528,8 @@ $tools_system{'Status'} = [ $fsurl.'view/Status.html', 'System status' ]
   if $curuser->access_right('Configuration'); # 'View system status');
 $tools_system{'Job Queue'} =  [ $fsurl.'search/queue.html', 'View pending job queue' ]
   if $curuser->access_right('Job queue');
+$tools_system{'Access log statistics'} = [ $fsurl.'search/report_access_user_log.html?group_by=path', '' ]
+  if $curuser->access_right('Configuration'); # 'View profiling data');
 
 tie my %tools_menu, 'Tie::IxHash', ();
 $tools_menu{'Customers'} = [ \%tools_customers, 'Customer tools' ]
diff --git a/httemplate/search/access_user_log.html b/httemplate/search/access_user_log.html
new file mode 100644
index 0000000..529ae86
--- /dev/null
+++ b/httemplate/search/access_user_log.html
@@ -0,0 +1,54 @@
+<& elements/search.html,
+                 'title'       => 'Access Log',
+                 'name'        => 'entries',
+                 'query'       => $query,
+                 'count_query' => $count_query,
+                 'header'      => [ 
+                                    'Path',
+                                    '#',
+                                    'Avg time',
+                                  ],
+                 'fields'      => [ sub { shift->path },
+                                    sub { shift->num_entries },
+                                    sub { shift->avg_render_seconds },
+                                  ],
+                 'sort_fields' => [qw( path num_entries avg_render_seconds )],
+             
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my %hashref = ();
+my @extra_sql = ();
+
+my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, '_date');
+push @extra_sql, "_date >= $beginning" if $beginning;
+push @extra_sql, "_date <= $ending"    if $ending;
+
+$hashref{usernum} = $cgi->param('usernum') if $cgi->param('usernum') =~ /^\d+$/;
+
+my $extra_sql = '';
+$extra_sql .=  (keys(%hashref) ? ' AND ' : ' WHERE ' ). join(' AND ', @extra_sql)
+  if @extra_sql;
+$extra_sql .= ' GROUP BY path '
+  if $cgi->param('group_by') eq 'path';
+warn $extra_sql;
+
+my $query = {
+  'select'    => join(' , ',
+                   'path',
+                   'COUNT(*) AS num_entries',
+                   'ROUND(AVG(COALESCE(render_seconds,0)),1) '.
+                           ' AS avg_render_seconds',
+                 ),
+  'table'     => 'access_user_log',
+  'hashref'   => \%hashref,
+  'extra_sql' => $extra_sql,
+};
+
+#uuh, no, need dates and usernum too, but whatever for now
+my $count_query = 'SELECT COUNT(DISTINCT path) FROM access_user_log';
+
+</%init>
diff --git a/httemplate/search/report_access_user_log.html b/httemplate/search/report_access_user_log.html
new file mode 100644
index 0000000..0c8acb3
--- /dev/null
+++ b/httemplate/search/report_access_user_log.html
@@ -0,0 +1,37 @@
+<& /elements/header.html, 'Access log' &>
+
+<FORM ACTION="access_user_log.html" METHOD="GET">
+
+<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
+  <INPUT TYPE="hidden" NAME="group_by" VALUE="<% $group_by %>">
+
+  <TR>
+    <TH CLASS="background" COLSPAN=2 ALIGN="left">
+      <FONT SIZE="+1">Search options</FONT>
+    </TH>
+  </TR>
+
+  <& /elements/tr-input-beginning_ending.html &>
+
+  <& /elements/tr-select-user.html &>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="Get Report">
+
+</FORM>
+
+<& /elements/footer.html &>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $group_by = '';
+if ( $cgi->param('group_by') =~ /^(\w+)$/ ) {
+  $group_by = $1;
+}
+
+</%init>

-----------------------------------------------------------------------

Summary of changes:
 httemplate/elements/menu.html                 |    2 +
 httemplate/search/access_user_log.html        |   54 +++++++++++++++++++++++++
 httemplate/search/report_access_user_log.html |   37 +++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 httemplate/search/access_user_log.html
 create mode 100644 httemplate/search/report_access_user_log.html




More information about the freeside-commits mailing list