& 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>