improving matrix performance
This commit is contained in:
parent
6a1bbead00
commit
66e4b23e7f
1 changed files with 15 additions and 24 deletions
|
|
@ -930,30 +930,22 @@ sub www_getCompareFormData {
|
||||||
listing.views,
|
listing.views,
|
||||||
listing.compares,
|
listing.compares,
|
||||||
listing.clicks,
|
listing.clicks,
|
||||||
listing.lastUpdated
|
listing.lastUpdated,
|
||||||
from MatrixListing as listing
|
max(assetData.revisionDate)
|
||||||
left join asset on listing.assetId = asset.assetId
|
from asset
|
||||||
left join assetData on assetData.assetId = listing.assetId and listing.revisionDate =
|
left join assetData using(assetId)
|
||||||
|
left join MatrixListing as listing on listing.assetId = assetData.assetId and listing.revisionDate =
|
||||||
assetData.revisionDate
|
assetData.revisionDate
|
||||||
where
|
where
|
||||||
asset.parentId=?
|
asset.parentId=?
|
||||||
and asset.state='published'
|
and asset.state='published'
|
||||||
and asset.className='WebGUI::Asset::MatrixListing'
|
and asset.className='WebGUI::Asset::MatrixListing'
|
||||||
and assetData.revisionDate=(
|
|
||||||
select
|
|
||||||
max(revisionDate)
|
|
||||||
from
|
|
||||||
assetData
|
|
||||||
where
|
|
||||||
assetData.assetId=asset.assetId
|
|
||||||
and (status='approved' or status='archived')
|
|
||||||
)
|
|
||||||
and status='approved'
|
and status='approved'
|
||||||
group by
|
group by assetData.assetId
|
||||||
assetData.assetId
|
|
||||||
order by ".$sort.$sortDirection;
|
order by ".$sort.$sortDirection;
|
||||||
|
|
||||||
@results = @{ $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]) };
|
@results = @{ $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]) };
|
||||||
|
|
||||||
foreach my $result (@results){
|
foreach my $result (@results){
|
||||||
if($form->process("search")){
|
if($form->process("search")){
|
||||||
# $self->session->errorHandler->warn("checking listing: ".$result->{title});
|
# $self->session->errorHandler->warn("checking listing: ".$result->{title});
|
||||||
|
|
@ -993,11 +985,11 @@ assetData.revisionDate
|
||||||
$result->{assetId} =~ s/-/_____/g;
|
$result->{assetId} =~ s/-/_____/g;
|
||||||
$result->{url} = $session->url->gateway($result->{url});
|
$result->{url} = $session->url->gateway($result->{url});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $jsonOutput;
|
my $jsonOutput;
|
||||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||||
|
|
||||||
return JSON->new->utf8->encode($jsonOutput);
|
my $encodedOutput = JSON->new->utf8->encode($jsonOutput);
|
||||||
|
return $encodedOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -1023,8 +1015,7 @@ sub www_getCompareListData {
|
||||||
unless (scalar(@listingIds)) {
|
unless (scalar(@listingIds)) {
|
||||||
@listingIds = $self->session->form->checkList("listingId");
|
@listingIds = $self->session->form->checkList("listingId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach my $listingId (@listingIds){
|
foreach my $listingId (@listingIds){
|
||||||
$listingId =~ s/_____/-/g;
|
$listingId =~ s/_____/-/g;
|
||||||
my $listing = WebGUI::Asset::MatrixListing->new($session,$listingId);
|
my $listing = WebGUI::Asset::MatrixListing->new($session,$listingId);
|
||||||
|
|
@ -1049,17 +1040,18 @@ sub www_getCompareListData {
|
||||||
my $fields = " a.name, a.fieldType, a.attributeId, a.description ";
|
my $fields = " a.name, a.fieldType, a.attributeId, a.description ";
|
||||||
my $from = "from Matrix_attribute a";
|
my $from = "from Matrix_attribute a";
|
||||||
my $tableCount = "b";
|
my $tableCount = "b";
|
||||||
|
my $where;
|
||||||
foreach my $listingId (@listingIds) {
|
foreach my $listingId (@listingIds) {
|
||||||
my $listingId_safe = $listingId;
|
my $listingId_safe = $listingId;
|
||||||
$listingId_safe =~ s/-/_____/g;
|
$listingId_safe =~ s/-/_____/g;
|
||||||
$fields .= ", ".$tableCount.".value as `$listingId_safe`";
|
$fields .= ", ".$tableCount.".value as `$listingId_safe`";
|
||||||
$from .= " left join MatrixListing_attribute ".$tableCount." on a.attributeId="
|
$from .= " left join MatrixListing_attribute ".$tableCount." on a.attributeId=".$tableCount.".attributeId";
|
||||||
.$tableCount.".attributeId and ".$tableCount.".matrixListingId=? ";
|
$where .= "and ".$tableCount.".matrixListingId=?";
|
||||||
$tableCount++;
|
$tableCount++;
|
||||||
}
|
}
|
||||||
push(@results, @{ $self->session->db->buildArrayRefOfHashRefs(
|
push(@results, @{ $self->session->db->buildArrayRefOfHashRefs(
|
||||||
"select $fields $from where a.category=? and a.assetId=? order by a.name",
|
"select $fields $from where a.category=? and a.assetId=? ".$where." order by a.name",
|
||||||
[@listingIds,$category,$self->getId]
|
[$category,$self->getId,@listingIds]
|
||||||
) });
|
) });
|
||||||
}
|
}
|
||||||
foreach my $result (@results){
|
foreach my $result (@results){
|
||||||
|
|
@ -1095,7 +1087,6 @@ sub www_getCompareListData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||||
|
|
||||||
$session->http->setMimeType("application/json");
|
$session->http->setMimeType("application/json");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue