ems performance improvements

This commit is contained in:
JT Smith 2007-07-05 04:18:16 +00:00
parent 36ed3f9209
commit e1a0b462a1
4 changed files with 28 additions and 12 deletions

View file

@ -3,6 +3,8 @@
subroutines directly in their files. See subroutines directly in their files. See
WebGUI::Operation::FormHelpers::www_formHelper and WebGUI::Operation::FormHelpers::www_formHelper and
WebGUI::Operation::Workflow::www_activityHelper for details. WebGUI::Operation::Workflow::www_activityHelper for details.
- Added pagination to purchase history in commerce.
- improved performance of EMS
- rfe: snippets should have titles too! - rfe: snippets should have titles too!
- Added a mechanism for using external folders for custom code. See - Added a mechanism for using external folders for custom code. See
sbin/preload.custom.example for details. sbin/preload.custom.example for details.

View file

@ -3262,7 +3262,7 @@ sub www_addEventsToBadge {
my ($purchaseId) = $self->session->db->quickArray("select purchaseId from EventManagementSystem_registrations where badgeId=? and productId=? and purchaseId != '' and returned=0 and purchaseId is not null limit 1",[$bid,$eventId]); my ($purchaseId) = $self->session->db->quickArray("select purchaseId from EventManagementSystem_registrations where badgeId=? and productId=? and purchaseId != '' and returned=0 and purchaseId is not null limit 1",[$bid,$eventId]);
$self->session->scratch->set("currentPurchase",$purchaseId); $self->session->scratch->set("currentPurchase",$purchaseId);
$self->session->db->write( $self->session->db->write(
"INSERT INTO EventManagementSystem_sessionPurchaseRef (sessionId, purchaseId, badgeId) VALUES (?,?,?)", "REPLACE INTO EventManagementSystem_sessionPurchaseRef (sessionId, purchaseId, badgeId) VALUES (?,?,?)",
[$self->session->getId, $purchaseId, $bid] [$self->session->getId, $purchaseId, $bid]
); );
} }
@ -3803,7 +3803,7 @@ sub www_search {
my $showAllFlag; my $showAllFlag;
my $addToBadgeMessage; my $addToBadgeMessage;
if ($eventAdded) { if ($eventAdded) {
$showAllFlag = 1; #$showAllFlag = 1;
$addToBadgeMessage = sprintf $i18n->get('add to badge message'), $eventAdded; $addToBadgeMessage = sprintf $i18n->get('add to badge message'), $eventAdded;
} }
if ($var{badgeSelected}) { if ($var{badgeSelected}) {
@ -3839,9 +3839,17 @@ sub www_search {
if (scalar(@keys)) { if (scalar(@keys)) {
#$searchPhrases = " and ( "; #$searchPhrases = " and ( ";
my $count = 0; my $count = 0;
foreach (@keys) { foreach my $word (@keys) {
if ($count) {
if ($word =~ m/^\d+$/) { # searching for a bunch of skus, so let's do an or instead
$searchPhrases .= ' or ';
}
else {
$searchPhrases .= ' and ';
}
}
$searchPhrases .= ' and ' if $count; $searchPhrases .= ' and ' if $count;
my $val = $self->session->db->quote('%'.$_.'%'); my $val = $self->session->db->quote('%'.$word.'%');
$searchPhrases .= "(p.title like $val or p.description like $val or p.sku like $val)"; $searchPhrases .= "(p.title like $val or p.description like $val or p.sku like $val)";
$count++; $count++;
} }
@ -4042,7 +4050,8 @@ sub www_search {
$eventFields{'purchase.label'} = $i18n->get('add to cart'); $eventFields{'purchase.label'} = $i18n->get('add to cart');
} }
my $masterEventId = $cfilter_t0 || $self->session->form->get("cfilter_t0"); my $masterEventId = $cfilter_t0 || $self->session->form->get("cfilter_t0");
$eventFields{'purchase.url'} = $self->getUrl('func=addToScratchCart;pid='.$event->{'productId'}.";mid=".$masterEventId.";pn=".$self->session->form->get("pn")); $eventFields{'purchase.url'} =
$self->getUrl('func=addToScratchCart;pid='.$event->{'productId'}.";mid=".$masterEventId.";pn=".$self->session->form->get("pn").";searchKeywords=".$self->session->form->get("searchKeywords"));
%eventFields = ('event' => $self->processTemplate(\%eventFields, $event->{'templateId'}), %eventFields) if ($self->{_calledFromView} && $self->session->form->process('func') eq 'view'); %eventFields = ('event' => $self->processTemplate(\%eventFields, $event->{'templateId'}), %eventFields) if ($self->{_calledFromView} && $self->session->form->process('func') eq 'view');
push (@events, \%eventFields); push (@events, \%eventFields);
} }

View file

@ -5,6 +5,7 @@ use WebGUI::Commerce::Transaction;
use WebGUI::Asset::Template; use WebGUI::Asset::Template;
use WebGUI::Operation; use WebGUI::Operation;
use WebGUI::Form; use WebGUI::Form;
use WebGUI::Paginator;
=head1 NAME =head1 NAME
@ -32,12 +33,14 @@ This error message will be added to the template variables.
sub www_viewPurchaseHistory { sub www_viewPurchaseHistory {
my $session = shift; my $session = shift;
my (@history, @historyLoop, %var, %properties); my (@historyLoop, %var, %properties);
$var{errorMessage} = shift; $var{errorMessage} = shift;
my $p = WebGUI::Paginator->new($session, $session->url->page("op=viewPurchaseHistory"));
@history = @{WebGUI::Commerce::Transaction->new($session)->transactionsByUser($session->user->userId)};
for my $transaction (@history) { my @history = reverse @{WebGUI::Commerce::Transaction->new($session)->transactionsByUser($session->user->userId)};
$p->setDataByArrayRef(\@history);
$p->appendTemplateVars(\%var);
for my $transaction (@{$p->getPageData}) {
%properties = %{$transaction->get}; %properties = %{$transaction->get};
$properties{initDate} = $session->datetime->epochToHuman($properties{initDate}); $properties{initDate} = $session->datetime->epochToHuman($properties{initDate});
$properties{completionDate} = $session->datetime->epochToHuman($properties{completionDate}) $properties{completionDate} = $session->datetime->epochToHuman($properties{completionDate})

View file

@ -2,7 +2,7 @@
//input. Each file upload input is named "file" the control must be rendered in a form. The //input. Each file upload input is named "file" the control must be rendered in a form. The
//Workspace id is the id of the div in the html page to render the control in. //Workspace id is the id of the div in the html page to render the control in.
function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit) { function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit, size) {
this.images = imageArray; this.images = imageArray;
this.fileLimit = fileLimit; this.fileLimit = fileLimit;
@ -21,7 +21,9 @@ function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit) {
str +='<table style="display: none;">' str +='<table style="display: none;">'
str += '<tr id="' + workspaceId + '.template" class="fileUploadRow"><td style="display:none;"><img src="' + imageArray["unknown"] + '" style="visibility: hidden;"></td>'; str += '<tr id="' + workspaceId + '.template" class="fileUploadRow"><td style="display:none;"><img src="' + imageArray["unknown"] + '" style="visibility: hidden;"></td>';
str +='<td colspan="2"><input type="file" name="'+fieldName+'" size="40" onchange="FileUploadControl_valueChange(event)"></td><td><input type="button" value="' + removeLabel + '" onclick="FileUploadControl_removeButtonClick(event)"></td></tr>'; str +='<td colspan="2"><input type="file" name="'+fieldName+'" ';
str += ' size="'+ size + '" ';
str +=' onchange="FileUploadControl_valueChange(event)"></td><td><input type="button" value="' + removeLabel + '" onclick="FileUploadControl_removeButtonClick(event)"></td></tr>';
str += '</table>'; str += '</table>';