fixed #9951: Matrix 2.0: Median not calculated correctly
This commit is contained in:
parent
1e38087d80
commit
814231b966
3 changed files with 35 additions and 1 deletions
|
|
@ -7,6 +7,7 @@
|
|||
forms (like the EMS sku's), simply display a button to take the user to the
|
||||
sku's view screen for the whole form. [TEMPLATE]
|
||||
- fixed #9933: Matrix 2.0 - Unable to view/edit product maintainer account
|
||||
- fixed #9951: Matrix 2.0: Median not calculated correctly
|
||||
|
||||
7.7.1
|
||||
- the AdSku project: create a Sku that allows buyers to purchase advertising in select AdSpaces at selected priorities
|
||||
|
|
|
|||
|
|
@ -32,8 +32,41 @@ my $session = start(); # this line required
|
|||
|
||||
# upgrade functions go here
|
||||
|
||||
recalculateMatrixListingMedianValue( $session );
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub recalculateMatrixListingMedianValue{
|
||||
my $session = shift;
|
||||
print "\tRecalculating median value for Matrix Listing ratings... \n" unless $quiet;
|
||||
my $matrices = WebGUI::Asset->getRoot($session)->getLineage(['descendants'],
|
||||
{
|
||||
statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'],
|
||||
statusToInclude => ['pending','approved','deleted','archived'],
|
||||
includeOnlyClasses => ['WebGUI::Asset::Wobject::Matrix'],
|
||||
returnObjects => 1,
|
||||
});
|
||||
|
||||
for my $matrix (@{$matrices})
|
||||
{
|
||||
next unless defined $matrix;
|
||||
my %categories = keys %{$matrix->getCategories};
|
||||
my $listings = $session->db->read("select distinct listingId from MatrixListing_rating where assetId = ?"
|
||||
,[$matrix->getId]);
|
||||
while (my $listing= $listings->hashRef){
|
||||
foreach my $category (%categories) {
|
||||
my $half = $session->db->quickScalar("select round((select count(*) from MatrixListing_rating where
|
||||
listingId = ? and category = ?)/2)",[$listing->{listingId},$category]);
|
||||
my $medianValue = $session->db->quickScalar("select rating from MatrixListing_rating where listingId =?
|
||||
and category =? order by rating limit $half,1;",[$listing->{listingId},$category]);
|
||||
$session->db->write("update MatrixListing_ratingSummary set medianValue = ? where listingId = ? and
|
||||
category = ?",[$medianValue,$listing->{listingId},$category]);
|
||||
}
|
||||
}
|
||||
}
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ sub setRatings {
|
|||
|
||||
my $half = round($count/2);
|
||||
my $mean = $sum / ($count || 1);
|
||||
my $median = $db->quickScalar("select rating $sql limit $half,$half",[$self->getId,$category]);
|
||||
my $median = $db->quickScalar("select rating $sql order by rating limit $half,1",[$self->getId,$category]);
|
||||
|
||||
$db->write("replace into MatrixListing_ratingSummary
|
||||
(listingId, category, meanValue, medianValue, countValue, assetId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue