some fairly major caching/searching prereqs changes
This commit is contained in:
parent
08b45ca68e
commit
3bf0fbab41
1 changed files with 52 additions and 20 deletions
|
|
@ -494,6 +494,8 @@ Utility method that checks for prerequisite groupings that no longer have any ev
|
||||||
sub deleteOrphans {
|
sub deleteOrphans {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
# MSW Note - as this is on 4/27/2006, I don't think query will ever return any results.
|
||||||
|
|
||||||
#Check for orphaned prerequisite definitions
|
#Check for orphaned prerequisite definitions
|
||||||
my @orphans = $self->session->db->quickArray("select p.prerequisiteId from EventManagementSystem_prerequisites as p
|
my @orphans = $self->session->db->quickArray("select p.prerequisiteId from EventManagementSystem_prerequisites as p
|
||||||
left join EventManagementSystem_prerequisiteEvents as pe
|
left join EventManagementSystem_prerequisiteEvents as pe
|
||||||
|
|
@ -1162,23 +1164,27 @@ sub resolveConflictForm {
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
sub verifyAllPrerequisites {
|
sub verifyAllPrerequisites {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $returnArrayFlag = shift;
|
# my $returnArrayFlag = shift;
|
||||||
my $cache;
|
my $cache;
|
||||||
my $pId;
|
my $pId;
|
||||||
if ($returnArrayFlag) {
|
# if ($returnArrayFlag) {
|
||||||
$pId = $self->getEventDetails($returnArrayFlag)->{prerequisiteId};
|
# $pId = $self->getEventDetails($returnArrayFlag)->{prerequisiteId};
|
||||||
$cache = WebGUI::Cache->new($self->session,["verifyAllPrerequisites",$pId]);
|
# $cache = WebGUI::Cache->new($self->session,["verifyAllPrerequisites",$pId]);
|
||||||
my $eventData = $cache->get;
|
# my $eventData = $cache->get;
|
||||||
return $eventData->{$pId} if defined $eventData->{$pId};
|
# return $eventData->{$pId} if defined $eventData->{$pId};
|
||||||
}
|
# }
|
||||||
#use Data::Dumper;
|
#use Data::Dumper;
|
||||||
#start with the events in the scratch cart. See if all prerequisites are met
|
#start with the events in the scratch cart. See if all prerequisites are met
|
||||||
my $startingEvents = {};
|
my $startingEvents = {};
|
||||||
my $scratchEvents = $self->getEventsInScratchCart;
|
my $scratchEvents;
|
||||||
foreach (@$scratchEvents) {
|
# if ($returnArrayFlag) {
|
||||||
$startingEvents->{$_} = $self->getEventDetails($_);
|
# $startingEvents = {$returnArrayFlag=>$self->getEventDetails($returnArrayFlag)};
|
||||||
}
|
# } else {
|
||||||
$startingEvents = {$returnArrayFlag=>$self->getEventDetails($returnArrayFlag)} if $returnArrayFlag;
|
$scratchEvents = $self->getEventsInScratchCart;
|
||||||
|
foreach (@$scratchEvents) {
|
||||||
|
$startingEvents->{$_} = $self->getEventDetails($_);
|
||||||
|
}
|
||||||
|
# }
|
||||||
my ($lastResults, $msgLoop) = $self->verifyEventPrerequisites($startingEvents,1);
|
my ($lastResults, $msgLoop) = $self->verifyEventPrerequisites($startingEvents,1);
|
||||||
my $lastResultsSize = scalar(keys %$lastResults);
|
my $lastResultsSize = scalar(keys %$lastResults);
|
||||||
my $currentResultsSize = -4;
|
my $currentResultsSize = -4;
|
||||||
|
|
@ -1199,11 +1205,11 @@ sub verifyAllPrerequisites {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rowsLoop = [];
|
my $rowsLoop = [];
|
||||||
if ($returnArrayFlag) {
|
# if ($returnArrayFlag) {
|
||||||
my @silliness = keys %$lastResults;
|
# my @silliness = keys %$lastResults;
|
||||||
$cache->set({$pId=>\@silliness}, 60*60*24*360);
|
# $cache->set({$pId=>\@silliness}, 60*60*24*360);
|
||||||
return \@silliness;
|
# return \@silliness;
|
||||||
}
|
# }
|
||||||
foreach (keys %$lastResults) {
|
foreach (keys %$lastResults) {
|
||||||
my $details = $lastResults->{$_};
|
my $details = $lastResults->{$_};
|
||||||
push(@$rowsLoop, {
|
push(@$rowsLoop, {
|
||||||
|
|
@ -1289,6 +1295,30 @@ sub getAllPossibleEventPrerequisites {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------
|
||||||
|
sub getAllPossibleRequiredEvents {
|
||||||
|
my $self = shift;
|
||||||
|
my $pId = shift;
|
||||||
|
$cache = WebGUI::Cache->new($self->session,["gAPRE",$pId]);
|
||||||
|
my $eventData = $cache->get;
|
||||||
|
return $eventData->{$pId} if defined $eventData->{$pId};
|
||||||
|
|
||||||
|
# Get all required events for this event (base case)
|
||||||
|
my $lastResults = $self->session->db->buildArrayRef("select distinct(r.requiredProductId) from EventManagementSystem_prerequisiteEvents as r where r.prerequisiteId = ?",[$pId]);
|
||||||
|
my $lastResultsSize = scalar(@$lastResults);
|
||||||
|
my $currentResultsSize = -4;
|
||||||
|
# initial case must not qualify as the base case
|
||||||
|
return [] unless $lastResultsSize;
|
||||||
|
until ($currentResultsSize == $lastResultsSize) {
|
||||||
|
$currentResultsSize = $lastResultsSize;
|
||||||
|
$lastResults = $self->session->db->buildArrayRef("select distinct(r.requiredProductId) from EventManagementSystem_prerequisiteEvents as r, EventManagementSystem_products as p where r.prerequisiteId = p.prerequisiteId and p.productId in (".$self->session->db->quoteAndJoin($lastResults).")");
|
||||||
|
$lastResultsSize = scalar(@$lastResults);
|
||||||
|
}
|
||||||
|
$cache->set({$pId=>$lastResults}, 60*60*24*360);
|
||||||
|
return $lastResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
sub getEventDetails {
|
sub getEventDetails {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
@ -2589,7 +2619,7 @@ sub www_search {
|
||||||
$searchPhrases &&= " and ( ".$searchPhrases." )";
|
$searchPhrases &&= " and ( ".$searchPhrases." )";
|
||||||
# $self->session->errorHandler->warn("searchPhrases: $searchPhrases<br />basicSearch: $basicSearch<br />");
|
# $self->session->errorHandler->warn("searchPhrases: $searchPhrases<br />basicSearch: $basicSearch<br />");
|
||||||
# Get the products available for sale for this page
|
# Get the products available for sale for this page
|
||||||
my $sql = "select p.productId, p.title, p.description, p.price, p.templateId, p.weight, p.sku, p.skuTemplate, e.approved, e.maximumAttendees, e.startDate, e.endDate $selects
|
my $sql = "select p.productId, p.title, p.description, p.price, p.templateId, p.weight, p.sku, p.skuTemplate, e.approved, e.maximumAttendees, e.startDate, e.endDate, e.prerequisiteId $selects
|
||||||
from products as p, EventManagementSystem_products as e
|
from products as p, EventManagementSystem_products as e
|
||||||
$joins
|
$joins
|
||||||
where
|
where
|
||||||
|
|
@ -2627,8 +2657,10 @@ sub www_search {
|
||||||
while ($data = $sth->hashRef) {
|
while ($data = $sth->hashRef) {
|
||||||
my $shouldPush = 1;
|
my $shouldPush = 1;
|
||||||
my $eventId = $data->{productId};
|
my $eventId = $data->{productId};
|
||||||
my $requiredList = $self->verifyAllPrerequisites($eventId);
|
my $requiredList =
|
||||||
# print "\nrequiredList: ".join(',',@$requiredList)." productId: ".$eventId;
|
($data->{prerequisiteId})
|
||||||
|
?$self->getAllPossibleRequiredEvents($data->{prerequisiteId})
|
||||||
|
:[];
|
||||||
if ($seatsAvailable ne 'none') {
|
if ($seatsAvailable ne 'none') {
|
||||||
my ($numberRegistered) = $self->session->db->quickArray("select count(*) from EventManagementSystem_registrations as r, EventManagementSystem_purchases as p
|
my ($numberRegistered) = $self->session->db->quickArray("select count(*) from EventManagementSystem_registrations as r, EventManagementSystem_purchases as p
|
||||||
where r.purchaseId = p.purchaseId and r.returned=0 and r.productId=".$self->session->db->quote($eventId));
|
where r.purchaseId = p.purchaseId and r.returned=0 and r.productId=".$self->session->db->quote($eventId));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue