diff --git a/lib/WebGUI/PassiveAnalytics/Flow.pm b/lib/WebGUI/PassiveAnalytics/Flow.pm
index 159483b8d..02e7fed8c 100644
--- a/lib/WebGUI/PassiveAnalytics/Flow.pm
+++ b/lib/WebGUI/PassiveAnalytics/Flow.pm
@@ -11,6 +11,7 @@ use WebGUI::Utility;
use WebGUI::HTMLForm;
use WebGUI::Workflow;
use WebGUI::Workflow::Instance;
+use WebGUI::User;
=head1 NAME
@@ -33,7 +34,11 @@ Returns true if an instance of the PassiveAnalytics workflow is active.
sub analysisActive {
my $session = shift;
- return $session->db->quickScalar(q!select count(*) from WorkflowInstance where workflowId='PassiveAnalytics000001'!);
+ my ($running, $startDate, $endDate, $userId) = $session->db->quickArray(q!select running, startDate, endDate, userId from passiveAnalyticsStatus!);
+ if (wantarray) {
+ return $running, $startDate, $endDate, WebGUI::User->new($session, $userId);
+ }
+ return $running;
}
#----------------------------------------------------------------------------
@@ -103,9 +108,13 @@ sub www_editRuleflow {
my $session = shift;
my $error = shift;
return $session->privilege->insufficient() unless canView($session);
+ my ($running, $startDate, $endDate, $user) = analysisActive($session);
if ($error) {
$error = qq|
$error
\n|;
}
+ elsif (!$running) {
+ $error = qq|Passive Analytics analysis completed on $endDate
\n|;
+ }
my $i18n = WebGUI::International->new($session, "PassiveAnalytics");
my $addmenu = '';
$addmenu .= sprintf '
%s',
@@ -127,8 +136,10 @@ sub www_editRuleflow {
label => $i18n->get('pause interval'),
hoverHelp => $i18n->get('pause interval help'),
);
- if (analysisActive($session)) {
- $f->raw('
| Passive Analytics analysis is currently active |
');
+ if ($running) {
+ $f->raw(sprintf <
username);
+| Passive Analytics analysis is currently active. Analysis was begun at %s by %s |
+EOD
}
else {
$f->submit(value => $i18n->get('Begin analysis'));
@@ -182,6 +193,7 @@ sub www_editRuleflowSave {
return www_editRuleflow($session, "Error creating the workflow instance.");
}
$instance->start('skipRealtime');
+ $session->db->write('update passiveAnalyticsStatus set startDate=NOW(), userId=?, endDate=?, running=1', [$session->user->userId, '']);
return www_editRuleflow($session);
}
@@ -247,7 +259,6 @@ sub www_editRuleSave {
'fooBarBaz' =~ qr/$regexp/;
};
if ($@) {
- $session->log->warn("Error: $@");
my $error = $@;
$error =~ s/at \S+?\.pm line \d+.*$//;
my $i18n = WebGUI::International->new($session, 'PassiveAnalytics');
diff --git a/lib/WebGUI/Workflow/Activity/BucketPassiveAnalytics.pm b/lib/WebGUI/Workflow/Activity/BucketPassiveAnalytics.pm
index 42dd8ea1d..712e70fa3 100644
--- a/lib/WebGUI/Workflow/Activity/BucketPassiveAnalytics.pm
+++ b/lib/WebGUI/Workflow/Activity/BucketPassiveAnalytics.pm
@@ -74,6 +74,7 @@ Analyze the deltaLog table, and generate the bucketLog table.
sub execute {
my ($self, undef, $instance) = @_;
my $session = $self->session;
+ sleep 45;
my $endTime = time() + $self->getTTL;
my $expired = 0;
@@ -139,6 +140,7 @@ EOSQL1
userId => $self->get('userId'),
message => $message,
});
+ $session->db->write('update passiveAnalyticsStatus set endDate=NOW(), running=0');
return $self->COMPLETE;
}
diff --git a/sbin/installPassiveAnalytics.pl b/sbin/installPassiveAnalytics.pl
index 45398e8f3..82c819a35 100644
--- a/sbin/installPassiveAnalytics.pl
+++ b/sbin/installPassiveAnalytics.pl
@@ -34,8 +34,8 @@ installLoggingTables($session);
installPassiveAnalyticsRule($session);
installPassiveAnalyticsConfig($session);
installWorkflow($session);
-#addAdminGroup($session);
addPassiveAnalyticsSettings($session);
+addPassiveAnalyticsStatus($session);
finish($session);
@@ -105,6 +105,28 @@ sub addPassiveAnalyticsSettings {
print "DONE!\n";
}
+#----------------------------------------------------------------------------
+# Add the PassiveAnalytics Rule table
+sub addPassiveAnalyticsStatus {
+ my $session = shift;
+ my $db = $session->db;
+ print "\tInstall Passive Analytics status table... ";
+ # and here's our code
+ $db->write(<write(<write('insert into passiveAnalyticsStatus (userId) VALUES (3)');
+ print "DONE!\n";
+}
+
#----------------------------------------------------------------------------
# Add the Passive Analytics config file entry
# for the adminConsole and the content handler