converted passive profile log thingy to workflow

This commit is contained in:
JT Smith 2006-03-03 16:34:57 +00:00
parent 2c3b6fc785
commit f215d28b51
5 changed files with 106 additions and 58 deletions

View file

@ -132,7 +132,8 @@ sub addWorkflow {
"WebGUI::Workflow::Activity::TrashExpiredEvents", "WebGUI::Workflow::Activity::CreateCronJob", "WebGUI::Workflow::Activity::DeleteExpiredSessions",
"WebGUI::Workflow::Activity::ExpireGroupings", "WebGUI::Workflow::Activity::PurgeOldAssetRevisions",
"WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "WebGUI::Workflow::Activity::PurgeOldTrash",
"WebGUI::Workflow::Activity::GetSyndicatedContent", "WebGUI::Workflow::Activity::ProcessRecurringPayments"],
"WebGUI::Workflow::Activity::GetSyndicatedContent", "WebGUI::Workflow::Activity::ProcessRecurringPayments",
"WebGUI::Workflow::Activity::SummarizePassiveProfileLog"],
"WebGUI::User"=>["WebGUI::Workflow::Activity::CreateCronJob"],
"WebGUI::VersionTag"=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag",
"WebGUI::Workflow::Activity::TrashVersionTag", "WebGUI::Workflow::Activity::CreateCronJob"]
@ -160,6 +161,8 @@ sub addWorkflow {
$activity->set("title", "deal with user groupings that have expired");
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "pbwfactivity0000000011");
$activity->set("title", "Expire old subscription codes");
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::SummarizePassiveProfileLog", "pbwfactivity0000000014");
$activity->set("title", "Summarize Passive Profiling Data");
WebGUI::Workflow::Cron->create($session, {
title=>'Daily Maintenance',
enabled=>1,
@ -220,6 +223,7 @@ sub addWorkflow {
$session->db->write("alter table assetVersionTag add column isLocked int not null default 0");
$session->db->write("alter table assetVersionTag add column lockedBy varchar(22) binary not null");
$session->config->delete("fileCacheSizeLimit");
$session->config->delete("passiveProfileInterval");
$session->config->delete("CleanLoginHistory_ageToDelete");
$session->config->delete("DecayKarma_minimumKarma");
$session->config->delete("DecayKarma_decayFactor");

View file

@ -276,13 +276,6 @@
"u" : "u_companyUrl"
},
# How often, in seconds, should WebGUI calculate the statistics
# of passively profiling users to content preferences. Note that
# this won't have any effect unless passive profiling is enabled
# in the UI.
"passiveProfileInterval" : 86400,
# What hour of the day (for example, 22 : 10 PM = 22:00:00)
# should WebGUI try to synchronize user profile information from
# the LDAP server. Note that this will only happen for users

View file

@ -0,0 +1,89 @@
package WebGUI::Workflow::Activity::SummarizePassiveProfileLog;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2006 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 WebGUI::PassiveProfiling;
=head1 NAME
Package WebGUI::Workflow::Activity::SummarizePassiveProfileLog;
=head1 DESCRIPTION
Calculates the statistics for passive profiling so that they may be used in the AOI macros.
=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::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_SummarizePassiveProfileLog");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> { }
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
return unless ($self->session->setting->get("passiveProfilingEnabled"));
my ($firstDate) = $self->session->db->quickArray("select min(dateOfEntry) from passiveProfileLog");
my $sessionExpired = time() - $self->session->setting->get("sessionTimeout");
# We process entries for registered users and expired visitor sessions
my $sql = "select * from passiveProfileLog where userId <> 1 or (userId = 1 and dateOfEntry < ?)";
my $sth = $self->session->db->read($sql, [$sessionExpired]);
while (my $data = $sth->hashRef) {
WebGUI::PassiveProfiling::summarizeAOI($self->session,$data);
$self->session->db->write("delete from passiveProfileLog where passiveProfileLogId = ?", [$data->{passiveProfileLogId}]);
}
$sth->finish;
}
1;

View file

@ -0,0 +1,12 @@
package WebGUI::i18n::English::Workflow_Activity_SummarizePassiveProfileLog;
our $I18N = {
'topicName' => {
message => q|Summarize Passive Profile Log|,
context => q|The name of this workflow activity.|,
lastUpdated => 0,
},
};
1;

View file

@ -1,50 +0,0 @@
package Hourly::SummarizePassiveProfileLog;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2006 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::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::PassiveProfiling;
use WebGUI::DateTime;
#-----------------------------------------
sub process {
my $verbose = shift;
unless ($session{setting}{passiveProfilingEnabled}) {
print " - Passive profiling is disabled." if ($verbose);
return;
}
my ($firstDate) = WebGUI::SQL->quickArray("select min(dateOfEntry) from passiveProfileLog");
my $interval = $session{config}{passiveProfileInterval} || 86400;
if (WebGUI::DateTime::time()-$firstDate < $interval) {
print " - Recently summarized: Skipping" if ($verbose);
return "";
}
my $sessionExpired = WebGUI::DateTime::time() - $session{setting}{sessionTimeout};
# We process entries for registered users and expired visitor sessions
my $sql = "select * from passiveProfileLog";
$sql .= " where userId <> 1 or (userId = 1 and dateOfEntry < ".quote($sessionExpired).")";
my $sth = WebGUI::SQL->read($sql);
while (my $data = $sth->hashRef) {
WebGUI::PassiveProfiling::summarizeAOI($data);
WebGUI::SQL->write("delete from passiveProfileLog where passiveProfileLogId = ".
quote($data->{passiveProfileLogId}));
}
$sth->finish;
}
1;