From e1a0b462a1c68f40539a229ff641682ee9afb613 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 5 Jul 2007 04:18:16 +0000 Subject: [PATCH] ems performance improvements --- docs/changelog/7.x.x.txt | 2 ++ .../Asset/Wobject/EventManagementSystem.pm | 19 ++++++++++++++----- lib/WebGUI/Operation/TransactionLog.pm | 13 ++++++++----- www/extras/FileUploadControl.js | 6 ++++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d906b292c..416307af5 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,8 @@ subroutines directly in their files. See WebGUI::Operation::FormHelpers::www_formHelper and WebGUI::Operation::Workflow::www_activityHelper for details. + - Added pagination to purchase history in commerce. + - improved performance of EMS - rfe: snippets should have titles too! - Added a mechanism for using external folders for custom code. See sbin/preload.custom.example for details. diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index ba8fa62b8..313005981 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -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]); $self->session->scratch->set("currentPurchase",$purchaseId); $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] ); } @@ -3803,7 +3803,7 @@ sub www_search { my $showAllFlag; my $addToBadgeMessage; if ($eventAdded) { - $showAllFlag = 1; + #$showAllFlag = 1; $addToBadgeMessage = sprintf $i18n->get('add to badge message'), $eventAdded; } if ($var{badgeSelected}) { @@ -3839,9 +3839,17 @@ sub www_search { if (scalar(@keys)) { #$searchPhrases = " and ( "; 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; - 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)"; $count++; } @@ -4042,7 +4050,8 @@ sub www_search { $eventFields{'purchase.label'} = $i18n->get('add to cart'); } 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'); push (@events, \%eventFields); } diff --git a/lib/WebGUI/Operation/TransactionLog.pm b/lib/WebGUI/Operation/TransactionLog.pm index f9246bb3d..c0be93f85 100644 --- a/lib/WebGUI/Operation/TransactionLog.pm +++ b/lib/WebGUI/Operation/TransactionLog.pm @@ -5,6 +5,7 @@ use WebGUI::Commerce::Transaction; use WebGUI::Asset::Template; use WebGUI::Operation; use WebGUI::Form; +use WebGUI::Paginator; =head1 NAME @@ -32,12 +33,14 @@ This error message will be added to the template variables. sub www_viewPurchaseHistory { my $session = shift; - my (@history, @historyLoop, %var, %properties); - + my (@historyLoop, %var, %properties); $var{errorMessage} = shift; - - @history = @{WebGUI::Commerce::Transaction->new($session)->transactionsByUser($session->user->userId)}; - for my $transaction (@history) { + my $p = WebGUI::Paginator->new($session, $session->url->page("op=viewPurchaseHistory")); + + 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{initDate} = $session->datetime->epochToHuman($properties{initDate}); $properties{completionDate} = $session->datetime->epochToHuman($properties{completionDate}) diff --git a/www/extras/FileUploadControl.js b/www/extras/FileUploadControl.js index 0e2a71be4..4dbd5757c 100755 --- a/www/extras/FileUploadControl.js +++ b/www/extras/FileUploadControl.js @@ -2,7 +2,7 @@ //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. -function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit) { +function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit, size) { this.images = imageArray; this.fileLimit = fileLimit; @@ -21,7 +21,9 @@ function FileUploadControl(fieldName, imageArray, removeLabel, fileLimit) { str +='' str += ''; - str +=''; + str +=''; str += '
';