updated the passive profiling system
This commit is contained in:
parent
01d95a265e
commit
cfa77c82fa
2 changed files with 48 additions and 40 deletions
|
|
@ -283,9 +283,8 @@ Logs the view of the wobject to the passive profiling mechanism.
|
||||||
sub logView {
|
sub logView {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
if ($self->session->setting->get("passiveProfilingEnabled")) {
|
if ($self->session->setting->get("passiveProfilingEnabled")) {
|
||||||
WebGUI::PassiveProfiling::add($self->get("assetId"));
|
WebGUI::PassiveProfiling::add($session,$self->get("assetId"));
|
||||||
# not sure what this will do in the new model
|
WebGUI::PassiveProfiling::addPage($session,$self->get("assetId")); # add wobjects on asset to passive profile log
|
||||||
# WebGUI::PassiveProfiling::addPage(); # add wobjects on asset to passive profile log
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,6 @@ package WebGUI::PassiveProfiling;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
use WebGUI::DateTime;
|
|
||||||
use WebGUI::Id;
|
|
||||||
use WebGUI::Session;
|
|
||||||
use WebGUI::SQL;
|
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -43,10 +39,14 @@ These functions/methods are available from this package:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 add ( assetId )
|
=head2 add ( session, assetId )
|
||||||
|
|
||||||
Adds a assetId to the passive profile log.
|
Adds a assetId to the passive profile log.
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the current session.
|
||||||
|
|
||||||
=head3 assetId
|
=head3 assetId
|
||||||
|
|
||||||
The assetId to add.
|
The assetId to add.
|
||||||
|
|
@ -54,48 +54,57 @@ The assetId to add.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub add {
|
sub add {
|
||||||
return unless ($self->session->setting->get("passiveProfilingEnabled"));
|
my $session = shift;
|
||||||
|
return unless ($session->setting->get("passiveProfilingEnabled"));
|
||||||
my $assetId = shift;
|
my $assetId = shift;
|
||||||
my $sql = "insert into passiveProfileLog (passiveProfileLogId, userId, sessionId, assetId, dateOfEntry)
|
my $sql = "insert into passiveProfileLog (passiveProfileLogId, userId, sessionId, assetId, dateOfEntry)
|
||||||
values (".$self->session->db->quote($self->session->id->generate()).",".
|
values (".$session->db->quote($session->id->generate()).",".
|
||||||
$self->session->db->quote($self->session->user->profileField("userId")).",".
|
$session->db->quote($session->user->profileField("userId")).",".
|
||||||
$self->session->db->quote($self->session->var->get("sessionId")).",".
|
$session->db->quote($session->var->get("sessionId")).",".
|
||||||
$self->session->db->quote($assetId).",".
|
$session->db->quote($assetId).",".
|
||||||
$self->session->db->quote($self->session->datetime->time()).")";
|
$session->db->quote($session->datetime->time()).")";
|
||||||
$self->session->db->write($sql);
|
$session->db->write($sql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 addPage ( [ pageId ] )
|
=head2 addPage ( session, assetId )
|
||||||
|
|
||||||
Adds all wobjects on current page to the passive profile log.
|
Adds all wobjects on current page to the passive profile log.
|
||||||
Optionally you can specify an alternate pageId.
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the current session.
|
||||||
|
|
||||||
=head3 pageId
|
=head3 assetId
|
||||||
|
|
||||||
The pageId of the page you want to log.
|
The assetId of the page you want to log.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addPage {
|
sub addPage {
|
||||||
return unless ($self->session->setting->get("passiveProfilingEnabled"));
|
my $session = shift;
|
||||||
my $pageId = shift || $session{page}{pageId};
|
return unless ($session->setting->get("passiveProfilingEnabled"));
|
||||||
my @wids = $self->session->db->buildArray("select * from wobject where pageId=".$self->session->db->quote($pageId));
|
my $pageId = shift;
|
||||||
|
my @wids = $session->db->buildArray("select assetId from asset where parentId=".$session->db->quote($pageId));
|
||||||
foreach my $wid (@wids) {
|
foreach my $wid (@wids) {
|
||||||
add($wid);
|
add($session,$wid);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 summarizeAOI ( hashRef )
|
=head2 summarizeAOI ( session, hashRef )
|
||||||
|
|
||||||
Summarizes passive profile log data using the metadata attributes. An entry
|
Summarizes passive profile log data using the metadata attributes. An entry
|
||||||
is logged in the passiveProfileAOI table.
|
is logged in the passiveProfileAOI table.
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the session.
|
||||||
|
|
||||||
=head3 hashRef
|
=head3 hashRef
|
||||||
|
|
||||||
A hashRef with userId and assetId.
|
A hashRef with userId and assetId.
|
||||||
|
|
@ -103,6 +112,7 @@ A hashRef with userId and assetId.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub summarizeAOI {
|
sub summarizeAOI {
|
||||||
|
my $session = shift;
|
||||||
my $data = shift;
|
my $data = shift;
|
||||||
my $sql = "
|
my $sql = "
|
||||||
select f.fieldName,
|
select f.fieldName,
|
||||||
|
|
@ -112,28 +122,27 @@ sub summarizeAOI {
|
||||||
d.value
|
d.value
|
||||||
from metaData_values d , metaData_properties f
|
from metaData_values d , metaData_properties f
|
||||||
where f.fieldId = d.fieldId
|
where f.fieldId = d.fieldId
|
||||||
and d.assetId = ".$self->session->db->quote($data->{assetId});
|
and d.assetId = ".$session->db->quote($data->{assetId});
|
||||||
|
|
||||||
my $sth = $self->session->db->read($sql);
|
my $sth = $session->db->read($sql);
|
||||||
while (my $field = $sth->hashRef) {
|
while (my $field = $sth->hashRef) {
|
||||||
my $aoi = $self->session->db->quickHashRef("select * from passiveProfileAOI
|
my $aoi = $session->db->quickHashRef("select * from passiveProfileAOI
|
||||||
where userId=".$self->session->db->quote($data->{userId})."
|
where userId=".$session->db->quote($data->{userId})."
|
||||||
and fieldId=".$self->session->db->quote($field->{fieldId})." and
|
and fieldId=".$session->db->quote($field->{fieldId})." and
|
||||||
value=".$self->session->db->quote($field->{value}));
|
value=".$session->db->quote($field->{value}));
|
||||||
if(not exists $aoi->{userId}) {
|
if(not exists $aoi->{userId}) {
|
||||||
# Add record to DB
|
# Add record to DB
|
||||||
$self->session->db->write("insert into passiveProfileAOI (userId, fieldId, value)
|
$session->db->write("insert into passiveProfileAOI (userId, fieldId, value)
|
||||||
values (".$self->session->db->quote($data->{userId}).",".
|
values (".$session->db->quote($data->{userId}).",".
|
||||||
$self->session->db->quote($field->{fieldId}).",".
|
$session->db->quote($field->{fieldId}).",".
|
||||||
$self->session->db->quote($field->{value}).")");
|
$session->db->quote($field->{value}).")");
|
||||||
}
|
}
|
||||||
my $count = $aoi->{count};
|
my $count = $aoi->{count};
|
||||||
$count++;
|
$count++;
|
||||||
|
$session->db->write("update passiveProfileAOI set count=".$session->db->quote($count)."
|
||||||
$self->session->db->write("update passiveProfileAOI set count=".$self->session->db->quote($count)."
|
where userId=".$session->db->quote($data->{userId})."
|
||||||
where userId=".$self->session->db->quote($data->{userId})."
|
and fieldId=".$session->db->quote($field->{fieldId})." and
|
||||||
and fieldId=".$self->session->db->quote($field->{fieldId})." and
|
value=".$session->db->quote($field->{value}));
|
||||||
value=".$self->session->db->quote($field->{value}));
|
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue