Dump WebGUI Statistics.
This commit is contained in:
parent
d31137c881
commit
d3b574da13
6 changed files with 21 additions and 410 deletions
|
|
@ -2,4 +2,5 @@
|
||||||
- Replaced the existing caching mechanism with memcached, which results in a 400% improvement to cache speed. See migration.txt for API changes and gotcha.txt for prereq changes.
|
- Replaced the existing caching mechanism with memcached, which results in a 400% improvement to cache speed. See migration.txt for API changes and gotcha.txt for prereq changes.
|
||||||
- Added "hot sessions" so sessions interact with the database less.
|
- Added "hot sessions" so sessions interact with the database less.
|
||||||
- Added Facebook Auth and FacebookLogin macro.
|
- Added Facebook Auth and FacebookLogin macro.
|
||||||
|
- Removed the WebGUI statistics program and code.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,13 +278,6 @@
|
||||||
"url" : "^PageUrl(\"\",func=manageClipboard);",
|
"url" : "^PageUrl(\"\",func=manageClipboard);",
|
||||||
"title" : "^International(948,WebGUI);"
|
"title" : "^International(948,WebGUI);"
|
||||||
},
|
},
|
||||||
"statistics" : {
|
|
||||||
"icon" : "statistics.gif",
|
|
||||||
"uiLevel" : 1,
|
|
||||||
"url" : "^PageUrl(\"\",op=viewStatistics);",
|
|
||||||
"title" : "^International(437,WebGUI);",
|
|
||||||
"groupSetting" : "groupIdAdminStatistics"
|
|
||||||
},
|
|
||||||
"users" : {
|
"users" : {
|
||||||
"icon" : "users.gif",
|
"icon" : "users.gif",
|
||||||
"uiLevel" : 5,
|
"uiLevel" : 5,
|
||||||
|
|
|
||||||
|
|
@ -1,242 +0,0 @@
|
||||||
package WebGUI::Operation::Statistics;
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# WebGUI is Copyright 2001-2012 Plain Black Corporation.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# Please read the legal notices (docs/legal.txt) and the license
|
|
||||||
# (docs/license.txt) that came with this distribution before using
|
|
||||||
# this software.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# http://www.plainblack.com info@plainblack.com
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use WebGUI::AdminConsole;
|
|
||||||
use WebGUI::International;
|
|
||||||
use WebGUI::Workflow::Cron;
|
|
||||||
use WebGUI::DateTime;
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
Package WebGUI::Operation::Statistics
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
Handles displaying statistics about WebGUI. This isn't page count, but rather information
|
|
||||||
about the number of assets, users, groups, etc.
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 _submenu ( $session, $workarea, $title, $help )
|
|
||||||
|
|
||||||
Utility routine for creating the AdminConsole for Statistics functions.
|
|
||||||
|
|
||||||
=head3 $session
|
|
||||||
|
|
||||||
The current WebGUI session object.
|
|
||||||
|
|
||||||
=head3 $workarea
|
|
||||||
|
|
||||||
The content to display to the user.
|
|
||||||
|
|
||||||
=head3 $title
|
|
||||||
|
|
||||||
The title of the Admin Console. This should be an entry in the i18n
|
|
||||||
table in the WebGUI namespace.
|
|
||||||
|
|
||||||
=head3 $help
|
|
||||||
|
|
||||||
An entry in the Help system in the WebGUI namespace. This will be shown
|
|
||||||
as a link to the user.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub _submenu {
|
|
||||||
my $session = shift;
|
|
||||||
my $workarea = shift;
|
|
||||||
my $title = shift;
|
|
||||||
my $i18n = WebGUI::International->new($session);
|
|
||||||
$title = $i18n->get($title) if ($title);
|
|
||||||
my $ac = WebGUI::AdminConsole->new($session,"statistics");
|
|
||||||
if ($session->setting->get("trackPageStatistics")) {
|
|
||||||
$ac->addSubmenuItem( $session->url->page('op=viewStatistics'), $i18n->get(144));
|
|
||||||
}
|
|
||||||
return $ac->render($workarea, $title);
|
|
||||||
}
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 canView ( session [, user] )
|
|
||||||
|
|
||||||
Returns true if the user can administrate this operation. user defaults to
|
|
||||||
the current user.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub canView {
|
|
||||||
my $session = shift;
|
|
||||||
my $user = shift || $session->user;
|
|
||||||
return $user->isInGroup( $session->setting->get("groupIdAdminStatistics") );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_disableSendWebguiStats ()
|
|
||||||
|
|
||||||
Deletes the workflow schedule that sends WebGUI statistics to webgui.org.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_disableSendWebguiStats {
|
|
||||||
my $session = shift;
|
|
||||||
return $session->privilege->adminOnly() unless canView($session);
|
|
||||||
my $task = WebGUI::Workflow::Cron->new($session, 'send_webgui_statistics');
|
|
||||||
$task->delete;
|
|
||||||
my $workflow = WebGUI::Workflow->new($session, 'send_webgui_statistics');
|
|
||||||
$workflow->set({enabled => 0});
|
|
||||||
return www_viewStatistics($session);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_enableSendWebguiStats ()
|
|
||||||
|
|
||||||
Creates the workflow schedule that sends WebGUI statistics to webgui.org.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_enableSendWebguiStats {
|
|
||||||
my $session = shift;
|
|
||||||
return $session->privilege->adminOnly() unless canView($session);
|
|
||||||
# we set the current hour, minute, and day of week to send in the stats so we don't DOS webgui.org
|
|
||||||
# by having everybody sending it at the same time
|
|
||||||
my $dt = WebGUI::DateTime->new($session, time());
|
|
||||||
WebGUI::Workflow::Cron->create($session, {
|
|
||||||
enabled => 1,
|
|
||||||
workflowId => 'send_webgui_statistics',
|
|
||||||
minuteOfHour => $dt->minute,
|
|
||||||
hourOfDay => $dt->hour,
|
|
||||||
dayOfWeek => ($dt->dow % 7),
|
|
||||||
dayOfMonth => '*',
|
|
||||||
monthOfYear => '*',
|
|
||||||
priority => 3,
|
|
||||||
title => 'Send WebGUI Statistics',
|
|
||||||
}, 'send_webgui_statistics');
|
|
||||||
my $workflow = WebGUI::Workflow->new($session, 'send_webgui_statistics');
|
|
||||||
$workflow->set({enabled => 1});
|
|
||||||
return www_viewStatistics($session);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_viewStatistics ( $session, $sent )
|
|
||||||
|
|
||||||
Displays information to the user about WebGUI statistics if they are
|
|
||||||
in group Admin (3).
|
|
||||||
|
|
||||||
=head3 Displayed information
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Newest WebGUI version.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Current WebGUI version, if different from newest.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of published assets.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of assets set to be packages.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of templates
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of sessions
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of users.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Number of groups.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_viewStatistics {
|
|
||||||
my $session = shift;
|
|
||||||
return $session->privilege->adminOnly() unless canView($session);
|
|
||||||
my ($output, $data);
|
|
||||||
my $i18n = WebGUI::International->new($session);
|
|
||||||
|
|
||||||
# Get the latest WebGUI version
|
|
||||||
my $url = "http://update.webgui.org/latest-version.txt";
|
|
||||||
my $cache = $session->cache;
|
|
||||||
my $version = $cache->compute( $url, sub {
|
|
||||||
my $ua = LWP::UserAgent->new(
|
|
||||||
env_proxy => 1,
|
|
||||||
agent => "WebGUI/" . $WebGUI::VERSION,
|
|
||||||
timeout => 30,
|
|
||||||
);
|
|
||||||
|
|
||||||
my $r = $ua->get( $url );
|
|
||||||
if ( $r->is_error ) {
|
|
||||||
$session->log->warn( "Could not get latest WebGUI version from '$url': " . $r->status_line );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $r->decoded_content;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
$output .= '<table>';
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(145).':</td><td class="tableData">'.$WebGUI::VERSION.'-'.$WebGUI::STATUS.'</td></tr>';
|
|
||||||
if ($version ne $WebGUI::VERSION) {
|
|
||||||
my @rev = split(/\./,$version);
|
|
||||||
|
|
||||||
$version = '<a href="http://update.webgui.org/'.$rev[0].'.x.x/webgui-'.$version.'.tar.gz">'.$version.'</a>';
|
|
||||||
}
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(349).':</td><td class="tableData">'.$version.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(*) from asset where state='published'");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(147).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(distinct assetId) from assetData where isPackage=1");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(794).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(distinct(assetId)) from template");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(792).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(*) from userSession");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(146).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(*) from users");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(149).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
($data) = $session->db->quickArray("select count(*) from groups");
|
|
||||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get(89).':</td><td class="tableData">'.$data.'</td></tr>';
|
|
||||||
$output .= '</table>';
|
|
||||||
|
|
||||||
$output .= q|<p>|.$i18n->get('why to send','Activity_SendWebguiStats').q|</p>|;
|
|
||||||
|
|
||||||
my $task = WebGUI::Workflow::Cron->new($session, 'send_webgui_statistics');
|
|
||||||
if (defined $task) {
|
|
||||||
$output .= q|<p><a href="|.$session->url->page("op=disableSendWebguiStats").q|">|.$i18n->get('disable','Activity_SendWebguiStats').q|</a></p>|;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$output .= q|<p><a href="|.$session->url->page("op=enableSendWebguiStats").q|">|.$i18n->get('enable','Activity_SendWebguiStats').q|</a></p>|;
|
|
||||||
}
|
|
||||||
$output .= q|<p><a href="http://www.webgui.org/stats">http://www.webgui.org/stats</a></p>|;
|
|
||||||
return _submenu($session,$output);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
|
|
@ -22,7 +22,6 @@ sub _get_steps {
|
||||||
return [qw(
|
return [qw(
|
||||||
adminAccount
|
adminAccount
|
||||||
companyInformation
|
companyInformation
|
||||||
siteStats
|
|
||||||
defaultStyle
|
defaultStyle
|
||||||
)];
|
)];
|
||||||
}
|
}
|
||||||
|
|
@ -296,58 +295,6 @@ sub www_companyInformationSave {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_siteStats ( )
|
|
||||||
|
|
||||||
Opt-in to the global WebGUI statistics
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_siteStats {
|
|
||||||
my ( $self ) = @_;
|
|
||||||
my $session = $self->session;
|
|
||||||
my $form = $session->form;
|
|
||||||
$session->response->setCacheControl("none");
|
|
||||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
|
||||||
|
|
||||||
my $enableForm = $self->getForm;
|
|
||||||
$enableForm->addField( "hidden", name => "enableStats", value => 1 );
|
|
||||||
$enableForm->addField( "submit", name => 'send', value => $i18n->get( 'enable', 'Activity_SendWebguiStats' ) );
|
|
||||||
|
|
||||||
my $disableForm = $self->getForm;
|
|
||||||
$disableForm->addField( "hidden", name => "enableStats", value => 0 );
|
|
||||||
$disableForm->addField( "submit", name => 'send', value => $i18n->get( 'disable', 'Activity_SendWebguiStats' ) );
|
|
||||||
|
|
||||||
my $output = '<h1>' . $i18n->get( 'topicName', 'Activity_SendWebguiStats' ) . '</h1>';
|
|
||||||
$output .= ' <p>' . $i18n->get( 'why to send', 'Activity_SendWebguiStats' ) . '</p>
|
|
||||||
<p>' . $i18n->get( 'would you participate', 'Activity_SendWebguiStats' ) . '</p>
|
|
||||||
<div style="float: left">' . $enableForm->toHtml . '</div><div style="float: left">'
|
|
||||||
. $disableForm->toHtml
|
|
||||||
. '</div>'
|
|
||||||
. '<div style="clear: both;"> </div>'
|
|
||||||
;
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_siteStatsSave ( )
|
|
||||||
|
|
||||||
Opt-in to the global WebGUI statistics
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_siteStatsSave {
|
|
||||||
my ( $self ) = @_;
|
|
||||||
my $session = $self->session;
|
|
||||||
my $form = $session->form;
|
|
||||||
use WebGUI::Operation::Statistics;
|
|
||||||
WebGUI::Operation::Statistics::www_enableSendWebguiStats($session) if ( $form->get("enableStats") );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_defaultStyle ( )
|
=head2 www_defaultStyle ( )
|
||||||
|
|
||||||
Choose the default site style
|
Choose the default site style
|
||||||
|
|
|
||||||
|
|
@ -1,108 +0,0 @@
|
||||||
package WebGUI::Workflow::Activity::SendWebguiStats;
|
|
||||||
|
|
||||||
|
|
||||||
=head1 LEGAL
|
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
WebGUI is Copyright 2001-2012 Plain Black Corporation.
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
Please read the legal notices (docs/legal.txt) and the license
|
|
||||||
(docs/license.txt) that came with this distribution before using
|
|
||||||
this software.
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
http://www.plainblack.com info@plainblack.com
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use base 'WebGUI::Workflow::Activity';
|
|
||||||
use HTTP::Request;
|
|
||||||
use HTTP::Request::Common qw(POST);
|
|
||||||
use LWP::UserAgent;
|
|
||||||
use Digest::MD5;
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
Package WebGUI::Workflow::Activity::SendWebguiStats
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
This activity publishes information about your site to webgui.org. No private data is shared. The data is then rolled up on webgui.org/stats
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
See WebGUI::Workflow::Activity for details on how to use any activity.
|
|
||||||
|
|
||||||
=head1 METHODS
|
|
||||||
|
|
||||||
These methods are available from this class:
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 definition ( session, definition )
|
|
||||||
|
|
||||||
See WebGUI::Workflow::Activity::definition() for details.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub definition {
|
|
||||||
my $class = shift;
|
|
||||||
my $session = shift;
|
|
||||||
my $definition = shift;
|
|
||||||
my $i18n = WebGUI::International->new($session, "Activity_SendWebguiStats");
|
|
||||||
push(@{$definition}, {
|
|
||||||
name=>$i18n->get("topicName"),
|
|
||||||
properties=> {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return $class->SUPER::definition($session,$definition);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 execute ( [ object ] )
|
|
||||||
|
|
||||||
See WebGUI::Workflow::Activity::execute() for details.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub execute {
|
|
||||||
my $self = shift;
|
|
||||||
my $object = shift;
|
|
||||||
my $instance = shift;
|
|
||||||
my $db = $self->session->db;
|
|
||||||
my $stats = {
|
|
||||||
webguiVersion => $WebGUI::VERSION,
|
|
||||||
perlVersion => sprintf("%vd", $^V),
|
|
||||||
apacheVersion => 'X',
|
|
||||||
osType => $^O,
|
|
||||||
siteId => Digest::MD5::md5_base64($self->session->config->get("sitename")->[0]), # only here to identify the site if the user submits their info a second time
|
|
||||||
userCount => $db->quickScalar("select count(*) from users"),
|
|
||||||
groupCount => $db->quickScalar("select count(*) from groups"),
|
|
||||||
assetCount => $db->quickScalar("select count(*) from asset where state='published'"),
|
|
||||||
packageCount => $db->quickScalar("select count(distinct assetId) from assetData where isPackage=1"),
|
|
||||||
assetTypes => $db->buildArrayRefOfHashRefs("select count(*) as quantity,className from asset group by className"),
|
|
||||||
};
|
|
||||||
my $statsAsJson = JSON->new->encode($stats);
|
|
||||||
my $userAgent = new LWP::UserAgent;
|
|
||||||
$userAgent->env_proxy;
|
|
||||||
$userAgent->agent("WebGUI/".$WebGUI::VERSION);
|
|
||||||
$userAgent->timeout(30);
|
|
||||||
my $request = POST 'https://www.webgui.org/stats', [ func => 'receiveStats', stats => $statsAsJson ];
|
|
||||||
my $response = $userAgent->request($request);
|
|
||||||
if ($response->is_error) {
|
|
||||||
$self->session->log->error("WebGUI Stats could not be sent.");
|
|
||||||
}
|
|
||||||
return $self->COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
#vim:ft=perl
|
|
||||||
20
share/upgrades/7.10.23-8.0.0/removeWebGUIStatistics.pl
Normal file
20
share/upgrades/7.10.23-8.0.0/removeWebGUIStatistics.pl
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
use WebGUI::Upgrade::Script;
|
||||||
|
use File::Spec;
|
||||||
|
use WebGUI::Paths;
|
||||||
|
use Cwd qw(realpath);
|
||||||
|
|
||||||
|
start_step "Removing WebGUI statistics workflows and code";
|
||||||
|
|
||||||
|
config->deleteFromHash( 'adminConsole', 'statistics' );
|
||||||
|
|
||||||
|
my $workflow = WebGUI::Workflow->new(session, 'send_webgui_statistics');
|
||||||
|
$workflow->delete;
|
||||||
|
##This may not be in there if it is not enabled.
|
||||||
|
my $task = WebGUI::Workflow::Cron->new(session, 'send_webgui_statistics');
|
||||||
|
$task && $task->delete;
|
||||||
|
|
||||||
|
my $webgui_root = realpath( File::Spec->catdir( WebGUI::Paths->configBase, (File::Spec->updir) x 1 ) );
|
||||||
|
unlink File::Spec->catfile($webgui_root, 'lib', 'WebGUI', 'Operation', 'Statistics.pm');
|
||||||
|
unlink File::Spec->catfile($webgui_root, 'lib', 'WebGUI', 'Workflow', 'Activity', 'SendWebguiStats.pm');
|
||||||
|
|
||||||
|
done;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue