Performance improvements with getting the lists of packages when there
are lots of assets.
This commit is contained in:
parent
d09015502e
commit
914620f5a4
3 changed files with 26 additions and 31 deletions
|
|
@ -85,33 +85,21 @@ Returns an array of hashes containing title, assetId, and className for all asse
|
|||
=cut
|
||||
|
||||
sub getPackageList {
|
||||
my $self = shift;
|
||||
my $sql = "
|
||||
select
|
||||
asset.assetId,
|
||||
assetData.revisionDate,
|
||||
asset.className,
|
||||
assetData.title
|
||||
from
|
||||
asset
|
||||
left join
|
||||
assetData on asset.assetId=assetData.assetId
|
||||
where
|
||||
assetData.isPackage=1
|
||||
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and
|
||||
(assetData.status='approved'";
|
||||
$sql .= " or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")) if ($self->session->scratch->get("versionTag"));
|
||||
$sql .= ")) and asset.state='published'";
|
||||
my $sth = $self->session->db->read($sql);
|
||||
# MySQL sorts this very slowly, so we do it ourselves
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $db = $session->db;
|
||||
my @packageIds = $db->buildArray("select distinct assetId from assetData where isPackage=1");
|
||||
my @assets;
|
||||
while (my ($id, $date, $class, $title) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->new($self->session, $id, $class, $date);
|
||||
push(@assets, [$title, $asset]) if ($asset->get("isPackage"));
|
||||
ID: foreach my $id (@packageIds) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($session, $id);
|
||||
next ID unless defined $asset;
|
||||
next ID unless $asset->canView && $asset->get('isPackage');
|
||||
next ID unless ($asset->get('status') eq 'approved' || $asset->get('tagId') eq $session->scratch->get("versionTag"));
|
||||
push @assets, [$asset->getTitle, $asset];
|
||||
}
|
||||
$sth->finish;
|
||||
@assets = map { $_->[1] } sort { $a->[0] cmp $b->[0] } @assets;
|
||||
return \@assets;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue