Fix a bug where ratings were allowed to be set with less than 10 votes. Fixes bug #11294

This helps fix people trying to game the system.
This commit is contained in:
Colin Kuskie 2009-12-08 14:39:24 -08:00
parent 5153d82327
commit d1e6f30493
5 changed files with 253 additions and 94 deletions

View file

@ -608,9 +608,11 @@ sub setRatings {
my $mean = $sum / ($count || 1);
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)
values (?,?,?,?,?,?)",[$self->getId,$category,$mean,$median,$count,$matrixId]);
if ($count >= 10) {
$db->write("replace into MatrixListing_ratingSummary
(listingId, category, meanValue, medianValue, countValue, assetId)
values (?,?,?,?,?,?)",[$self->getId,$category,$mean,$median,$count,$matrixId]);
}
}
return undef;
}