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
|
|
@ -5,6 +5,7 @@
|
|||
- fixed #10526: icalInterval in Calendar.pm
|
||||
- fixed: displaying performance profile data only to an allowed IP address.
|
||||
- fixed #10528: Thingy css error
|
||||
- fixed: Performance improvements with getting the list of asset packages.
|
||||
|
||||
7.7.10
|
||||
- Made a change to LDAP auth that adds an OR to that query so that it also searches for a row with fieldData REGEXP '^uid=(value-from-ldap-directory-server),'. (Wes Morgan)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@ use WebGUI::VersionTag;
|
|||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::MockObject;
|
||||
plan tests => 6;
|
||||
plan tests => 10;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
is(scalar @{ $root->getPackageList }, 0, 'WebGUI does not ship with packages');
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->tagsToRollback($versionTag);
|
||||
$versionTag->set({name=>"Asset Package test"});
|
||||
|
||||
my $folder = $root->addChild({
|
||||
|
|
@ -71,24 +75,26 @@ is(scalar @{ $targetFolderChildren }, 1, 'target folder now has 1 child');
|
|||
my $deployedFolder = $targetFolderChildren->[0];
|
||||
|
||||
is($deployedFolder->get('title'), 'folder', 'deployed folder has correct title');
|
||||
ok(! $deployedFolder->get('isPackage'), 'and is not a package');
|
||||
|
||||
my $deployedFolderChildren;
|
||||
$deployedFolderChildren = $deployedFolder->getLineage(["children"], {returnObjects => 1,});
|
||||
is(scalar @{ $deployedFolderChildren }, 1, 'deployed package folder still has 1 child');
|
||||
isa_ok($deployedFolderChildren->[0] , 'WebGUI::Asset::Snippet', 'deployed child is a Snippet');
|
||||
|
||||
##Unset isPackage in this versionTag for the next tests
|
||||
$folder->update({isPackage => 0});
|
||||
|
||||
my $newVersionTag = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->tagsToRollback($newVersionTag);
|
||||
$newVersionTag->commit;
|
||||
|
||||
my $newFolder = WebGUI::Asset->new($session, $folder->getId);
|
||||
ok(! $newFolder->get('isPackage'), 'Disabled isPackage in original folder asset');
|
||||
is(scalar @{ $root->getPackageList }, 0, 'getPackageList does not pick up old versions of assets that used to be packages');
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'Check package deployment with 2-level package and look for new style templates propagating down the tree');
|
||||
}
|
||||
|
||||
END {
|
||||
foreach my $tag($versionTag, $newVersionTag) {
|
||||
if (defined $tag and ref $tag eq 'WebGUI::VersionTag') {
|
||||
$tag->rollback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue