r78415 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78414‎ | r78415 | r78416 >
Date:00:21, 15 December 2010
Author:reedy
Status:deferred
Tags:
Comment:
Followup r78409, fix tired coding

Make the rating changes more readable/obvious, with description
Modified paths:
  • /trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php
@@ -85,14 +85,22 @@
8686 private function insertPageRating( $pageId, $ratingId, $updateAddition, $thisRating, $lastRating ) {
8787 $dbw = wfGetDB( DB_MASTER );
8888
89 - $newRating = ( $lastRating === false && $thisRating !== false );
 89+ // 0 == No change in rating count
 90+ // 1 == No rating last time (or new rating), and now there is
 91+ // -1 == Rating last time, but abstained this time
9092 $countChange = 0;
91 - if ( $newRating ) {
92 - $countChange = 1; // Garunteed new rating
93 - } else if ( $lastRating === 0 && $thisRating !== 0 ) {
94 - $countChange = 1; // "New" rating as last was 0 (abstained)
95 - } else if ( $lastRating !== 0 && $thisRating === 0 ) {
96 - $countChange = -1; // Rating abstained this time, but there was a prior rating
 93+ if ( $lastRating === false || $lastRating === 0 ) {
 94+ if ( $newRating === 0 ) {
 95+ $countChange = 0;
 96+ } else {
 97+ $countChange = 1;
 98+ }
 99+ } else { // Last rating was > 0
 100+ if ( $newRating === 0 ) {
 101+ $countChange = -1;
 102+ } else {
 103+ $countChange = 0;
 104+ }
97105 }
98106
99107 $dbw->insert(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78409Allow rating abstination, alter the count whether it's a new rating, a remove...reedy23:28, 14 December 2010

Status & tagging log