Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php |
— | — | @@ -623,7 +623,7 @@ |
624 | 624 | return $html; |
625 | 625 | } |
626 | 626 | |
627 | | - public static function getVoteAggregates( $page, $period ) { |
| 627 | + public static function getVoteAggregates( $page, $period, $add = array() ) { |
628 | 628 | global $wgLang, $wgMemc; |
629 | 629 | if( $period > 93 ) { |
630 | 630 | return ''; // too big |
— | — | @@ -681,6 +681,12 @@ |
682 | 682 | } |
683 | 683 | } |
684 | 684 | } |
| 685 | + // Tack on $add for display (used to avoid cache/lag) |
| 686 | + foreach( $add as $tag => $val ) { |
| 687 | + if( isset($votes[$tag]) && isset($votes[$tag][$val]) ) { |
| 688 | + $votes[$tag][$val]++; |
| 689 | + } |
| 690 | + } |
685 | 691 | $wgMemc->set( $key, array( $votes, $now ), 24*3600 ); |
686 | 692 | } |
687 | 693 | // Output multi-column list |
— | — | @@ -688,8 +694,13 @@ |
689 | 695 | foreach( FlaggedRevs::getFeedbackTags() as $tag => $w ) { |
690 | 696 | // Get tag average... |
691 | 697 | $dist = isset($votes[$tag]) ? $votes[$tag] : array(); |
692 | | - $ave = ($dist[0] + 2*$dist[1] + 3*$dist[2] + 4*$dist[3] + 5*$dist[4])/array_sum($dist); |
693 | | - $ave = round($ave,1); |
| 698 | + $count = array_sum($dist); |
| 699 | + if( $count ) { |
| 700 | + $ave = ($dist[0] + 2*$dist[1] + 3*$dist[2] + 4*$dist[3] + 5*$dist[4])/$count; |
| 701 | + $ave = round($ave,1); |
| 702 | + } else { |
| 703 | + $ave = '-'; // DIV by zero |
| 704 | + } |
694 | 705 | $html .= '<td align="center"><b>'.wfMsgHtml("readerfeedback-$tag").'</b> '. |
695 | 706 | '<sup>('.wfMsgHtml('ratinghistory-ave',$wgLang->formatNum($ave)).')</sup></td>'; |
696 | 707 | } |
Index: trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | $talk = $form->page->getTalkPage(); |
167 | 167 | |
168 | 168 | wfLoadExtensionMessages( 'RatingHistory' ); |
169 | | - $tallyTable = RatingHistory::getVoteAggregates( $form->page, 31 ); |
| 169 | + $tallyTable = RatingHistory::getVoteAggregates( $form->page, 31, $form->dims ); |
170 | 170 | |
171 | 171 | $dbw = wfGetDB( DB_MASTER ); |
172 | 172 | $dbw->begin(); |