Fix for AssetLineage's getChildCount. It did not consider the

asset's status, only the state.  Change the SQL query to always
look at status, and consider state based on the options passed
to the method.
Add two quick tests to test that.  More to follow.
This commit is contained in:
Colin Kuskie 2007-11-20 04:46:45 +00:00
parent ced6e64aff
commit 0799d70428
2 changed files with 12 additions and 7 deletions

View file

@ -170,7 +170,7 @@ sub formatRank {
=head2 getChildCount ( opts )
Returns the number of children this asset has. This excludes assets in the trash or clipbaord.
Returns the number of children this asset has. This excludes assets in the trash or clipboard.
=head3 opts
@ -186,8 +186,8 @@ only those that are published or achived are counted.
sub getChildCount {
my $self = shift;
my $opts = shift || {};
my $stateWhere = $opts->{includeTrash} ? '' : "state in ('published','archived') and";
my ($count) = $self->session->db->quickArray("select count(*) from asset where $stateWhere parentId=?", [$self->getId]);
my $stateWhere = $opts->{includeTrash} ? '' : "asset.state='published' and";
my ($count) = $self->session->db->quickArray("select count(asset.state) from asset, assetData where asset.assetId=assetData.assetId and $stateWhere parentId=? and assetData.status in ('approved', 'archived')", [$self->getId]);
return $count;
}