r100324 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100323‎ | r100324 | r100325 >
Date:02:17, 20 October 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
fix rounding issues with votes
Modified paths:
  • /trunk/extensions/Contest/Contest.hooks.php (modified) (history)
  • /trunk/extensions/Contest/Contest.sql (modified) (history)
  • /trunk/extensions/Contest/includes/ContestContestant.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestantPager.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)
  • /trunk/extensions/Contest/sql/UpdateContestantRatingField.sql (added) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.hooks.php
@@ -37,6 +37,12 @@
3838 dirname( __FILE__ ) . '/sql/AddContestEmailFields.sql',
3939 true
4040 ) );
 41+
 42+ $updater->addExtensionUpdate( array(
 43+ 'applyPatch',
 44+ dirname( __FILE__ ) . '/sql/UpdateContestantRatingField.sql',
 45+ true
 46+ ) );
4147
4248 return true;
4349 }
Index: trunk/extensions/Contest/sql/UpdateContestantRatingField.sql
@@ -0,0 +1 @@
 2+ALTER TABLE /*_*/contest_contestants MODIFY contestant_rating SMALLINT unsigned NOT NULL;
\ No newline at end of file
Property changes on: trunk/extensions/Contest/sql/UpdateContestantRatingField.sql
___________________________________________________________________
Added: svn:eol-style
13 + native
Index: trunk/extensions/Contest/specials/SpecialContestant.php
@@ -205,7 +205,7 @@
206206 $stats['rating'] = htmlspecialchars( wfMsgExt(
207207 'contest-contestant-rating',
208208 'parsemag',
209 - $this->getLang()->formatNum( $contestant->getField( 'rating' ) ),
 209+ $this->getLang()->formatNum( $contestant->getField( 'rating' ) / 100 ),
210210 $this->getLang()->formatNum( $contestant->getField( 'rating_count' ) )
211211 ) );
212212
Index: trunk/extensions/Contest/includes/ContestantPager.php
@@ -220,7 +220,7 @@
221221 $value = htmlspecialchars( wfMsgExt(
222222 'contest-contestant-rating',
223223 'parsemag',
224 - $this->getLang()->formatNum( $value ),
 224+ $this->getLang()->formatNum( $value / 100 ),
225225 $this->getLang()->formatNum( $this->mCurrentRow->contestant_rating_count )
226226 ) );
227227 break;
Index: trunk/extensions/Contest/includes/ContestContestant.php
@@ -558,7 +558,7 @@
559559 }
560560
561561 $this->setField( 'rating_count', $amount );
562 - $this->setField( 'rating', $amount > 0 ? $total / $amount : 0 );
 562+ $this->setField( 'rating', $amount > 0 ? $total / $amount * 100 : 0 );
563563 }
564564
565565 /**
Index: trunk/extensions/Contest/Contest.sql
@@ -41,7 +41,7 @@
4242
4343 contestant_submission TINYBLOB NOT NULL, -- URL to the users submission
4444
45 - contestant_rating TINYINT unsigned NOT NULL, -- The average rating of the contestant
 45+ contestant_rating SMALLINT unsigned NOT NULL, -- The average rating of the contestant, multiplied by 100 for precision
4646 contestant_rating_count SMALLINT unsigned NOT NULL, -- The number of ratings
4747 contestant_comments SMALLINT unsigned NOT NULL -- The number of comments
4848 ) /*$wgDBTableOptions*/;

Follow-up revisions

RevisionCommit summaryAuthorDate
r1003551.18wmf1 MFT r100324reedy17:38, 20 October 2011

Comments

#Comment by Reedy (talk | contribs)   02:29, 20 October 2011

Wouldn't this be better kept as a float/double?

Status & tagging log