From d1680cf8677b4ab46bbe90b5ec2b6e2507c937af Mon Sep 17 00:00:00 2001 From: Yung Han Khoe Date: Sun, 15 Feb 2009 16:08:48 +0000 Subject: [PATCH] matrix search fixes and performance improvements --- lib/WebGUI/Asset/Wobject/Matrix.pm | 41 ++++++++++++++--------- www/extras/wobject/Matrix/matrixSearch.js | 10 ++---- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index aa9ae50d6..9cf1dc9d3 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -945,34 +945,43 @@ assetData.revisionDate @results = @{ $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]) }; + my (@searchParams,@searchParams_sorted); + if($form->process("search")){ + foreach my $param ($form->param) { + if($param =~ m/^search_/){ + my $parameter; + $parameter->{name} = $param; + $parameter->{value} = $form->process($param); + my $attributeId = $param; + $attributeId =~ s/^search_//; + $attributeId =~ s/_____/-/g; + $parameter->{attributeId} = $attributeId; + push(@searchParams,$parameter); + } + } + } + @searchParams_sorted = sort { $b->{value} <=> $a->{value} } @searchParams; foreach my $result (@results){ if($form->process("search")){ - # $self->session->errorHandler->warn("checking listing: ".$result->{title}); my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs(" select value, fieldType, attributeId from MatrixListing_attribute as listing left join Matrix_attribute using(attributeId) - where listing.matrixListingId = ? - ",[$result->{assetId}],'attributeId'); - foreach my $param ($form->param) { - if($param =~ m/^search_/){ - my $attributeId = $param; - $attributeId =~ s/^search_//; - $attributeId =~ s/_____/-/; - my $fieldType = $matrixListing_attributes->{$attributeId}->{fieldType}; - my $listingValue = $matrixListing_attributes->{$attributeId}->{value}; - # $self->session->errorHandler->warn("fieldType:".$fieldType.", attributeValue: ".$form->process($param).", listingvalue: ".$listingValue); - if(($fieldType eq 'MatrixCompare') && ($listingValue < $form->process($param))){ + where listing.matrixListingId = ? order by value asc", + [$result->{assetId}],'attributeId'); + PARAM: foreach my $param (@searchParams_sorted) { + my $fieldType = $matrixListing_attributes->{$param->{attributeId}}->{fieldType}; + my $listingValue = $matrixListing_attributes->{$param->{attributeId}}->{value}; + if(($fieldType eq 'MatrixCompare') && ($listingValue < $param->{value})){ $result->{checked} = ''; - last; + last PARAM; } - elsif(($fieldType ne 'MatrixCompare') && ($form->process($param) ne $listingValue)){ + elsif(($fieldType ne 'MatrixCompare' && $fieldType ne '') && ($param->{value} ne $listingValue)){ $result->{checked} = ''; - last; + last PARAM; } else{ $result->{checked} = 'checked'; } - } } } else{ diff --git a/www/extras/wobject/Matrix/matrixSearch.js b/www/extras/wobject/Matrix/matrixSearch.js index dbea4e00c..ed312b0a1 100644 --- a/www/extras/wobject/Matrix/matrixSearch.js +++ b/www/extras/wobject/Matrix/matrixSearch.js @@ -37,16 +37,11 @@ YAHOO.util.Event.addListener(window, "load", function() { var myDataTable = new YAHOO.widget.DataTable("compareForm", myColumnDefs, this.myDataSource, {initialRequest:uri}); - this.myDataSource.doBeforeParseData = function (oRequest, oFullResponse) { - myDataTable.getRecordSet().reset(); - return oFullResponse; - } var myDataSource = this.myDataSource; var myCallback = function() { - myDataTable.getRecordSet().reset(); - this.set("sortedBy", null); - this.onDataReturnAppendRows.apply(this,arguments); + this.set("sortedBy", null); + this.onDataReturnAppendRows.apply(this,arguments); compareFormButton(); }; @@ -66,6 +61,7 @@ YAHOO.util.Event.addListener(window, "load", function() { } myDataTable.getRecordSet().reset(); myDataTable.refreshView(); + myDataTable.showTableMessage('Loading...'); myDataSource.sendRequest(newUri,callback2);