fixed a bug in Matrix deleteAttribute method
This commit is contained in:
parent
bde609f5cb
commit
a4207e7ec5
2 changed files with 28 additions and 0 deletions
|
|
@ -449,6 +449,23 @@ sub setRatings {
|
||||||
|
|
||||||
=head2 view ( hasRated )
|
=head2 view ( hasRated )
|
||||||
|
|
||||||
|
Updates the score of a MatrixListing.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub updateScore {
|
||||||
|
my $self = shift;
|
||||||
|
my $score = $self->session->db->quickScalar("select sum(value) from MatrixListing_attribute
|
||||||
|
left join Matrix_attribute using(attributeId)
|
||||||
|
where matrixListingId = ? and fieldType = 'MatrixCompare'",[$self->getId]);
|
||||||
|
$self->update({score => $score});
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 view ( hasRated )
|
||||||
|
|
||||||
method called by the container www_view method.
|
method called by the container www_view method.
|
||||||
|
|
||||||
=head3 hasRated
|
=head3 hasRated
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,17 @@ sub deleteAttribute {
|
||||||
my $attributeId = shift;
|
my $attributeId = shift;
|
||||||
|
|
||||||
$self->deleteCollateral("Matrix_attribute","attributeId",$attributeId);
|
$self->deleteCollateral("Matrix_attribute","attributeId",$attributeId);
|
||||||
|
$self->session->db->write("delete from MatrixListing_attribute where attributeId=? and matrixId=?",
|
||||||
|
[$attributeId,$self->getId]);
|
||||||
|
|
||||||
|
# recalculate scores for MatrixListings
|
||||||
|
my @listings = @{ $self->getLineage(['descendants'], {
|
||||||
|
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
|
||||||
|
returnObjects => 1,
|
||||||
|
}) };
|
||||||
|
foreach my $listing (@listings){
|
||||||
|
$listing->updateScore;
|
||||||
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue