fixed: Package search is slow for large websites

This commit is contained in:
Graham Knop 2008-04-15 22:36:44 +00:00
parent 8ec2c763b4
commit 5d597b709c
2 changed files with 14 additions and 10 deletions

View file

@ -1,6 +1,7 @@
7.5.11 7.5.11
- fix: template variable isUncommitted is not documented in the help - fix: template variable isUncommitted is not documented in the help
- fix: Event is no longer editable by anyone who can add events - fix: Event is no longer editable by anyone who can add events
- fixed: Package search is slow for large websites
7.5.10 7.5.10
- fix: Syntax error in GetCsMail - fix: Syntax error in GetCsMail

View file

@ -86,12 +86,12 @@ Returns an array of hashes containing title, assetId, and className for all asse
sub getPackageList { sub getPackageList {
my $self = shift; my $self = shift;
my @assets;
my $sql = " my $sql = "
select select
asset.assetId, asset.assetId,
assetData.revisionDate, assetData.revisionDate,
asset.className asset.className,
assetData.title
from from
asset asset
left join left join
@ -101,14 +101,17 @@ sub getPackageList {
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and
(assetData.status='approved'"; (assetData.status='approved'";
$sql .= " or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")) if ($self->session->scratch->get("versionTag")); $sql .= " or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")) if ($self->session->scratch->get("versionTag"));
$sql .= ")) and asset.state='published' group by assetData.assetId order by assetData.title desc"; $sql .= ")) and asset.state='published'";
my $sth = $self->session->db->read($sql); my $sth = $self->session->db->read($sql);
while (my ($id, $date, $class) = $sth->array) { # MySQL sorts this very slowly, so we do it ourselves
my $asset = WebGUI::Asset->new($self->session, $id,$class); my @assets;
push(@assets, $asset) if ($asset->get("isPackage")); while (my ($id, $date, $class, $title) = $sth->array) {
} my $asset = WebGUI::Asset->new($self->session, $id, $class, $date);
$sth->finish; push(@assets, [$title, $asset]) if ($asset->get("isPackage"));
return \@assets; }
$sth->finish;
@assets = map { $_->[1] } sort { $a->[0] cmp $b->[0] } @assets;
return \@assets;
} }