Index: trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php |
— | — | @@ -19,9 +19,12 @@ |
20 | 20 | 'ratinghistory-year' => 'last year', |
21 | 21 | 'ratinghistory-3years' => 'last 3 years', |
22 | 22 | 'ratinghistory-chart' => 'Reader feedback rating over time', |
| 23 | + 'ratinghistory-table' => 'Overview of last month', |
23 | 24 | 'ratinghistory-users' => 'Users who gave ratings', |
24 | 25 | 'ratinghistory-graph' => '$2 of "$3" ($1 {{PLURAL:$1|review|reviews}})', |
25 | 26 | 'readerfeedback-svg' => 'View as SVG', |
| 27 | + 'ratinghistory-table-rating' => 'Rating', |
| 28 | + 'ratinghistory-table-votes' => 'Votes', |
26 | 29 | 'ratinghistory-none' => 'There is not enough reader feedback data available for graphs at this time.', |
27 | 30 | 'ratinghistory-legend' => 'The \'\'\'daily average rating\'\'\' <font color="blue">\'\'(blue)\'\'</font> and |
28 | 31 | \'\'\'running average rating\'\'\' <font color="green">\'\'(green)\'\'</font> are graphed below, by date. The |
Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php |
— | — | @@ -63,9 +63,19 @@ |
64 | 64 | } else { |
65 | 65 | $wgOut->enableClientCache( false ); // don't show stale graphs |
66 | 66 | } |
| 67 | + $this->showTable(); |
67 | 68 | $this->showGraphs(); |
68 | 69 | } |
69 | 70 | |
| 71 | + protected function showTable() { |
| 72 | + global $wgOut; |
| 73 | + # Show latest month of results |
| 74 | + $html = $this->getVoteAggregates( 31 ); |
| 75 | + if( $html ) { |
| 76 | + $wgOut->addHTML( '<h2>'.wfMsgHtml('ratinghistory-table')."</h2>\n".$html ); |
| 77 | + } |
| 78 | + } |
| 79 | + |
70 | 80 | protected function showHeader() { |
71 | 81 | global $wgOut; |
72 | 82 | $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) ); |
— | — | @@ -269,6 +279,7 @@ |
270 | 280 | $totalVal += (int)$row->rfh_total; |
271 | 281 | $totalCount += (int)$row->rfh_count; |
272 | 282 | $dayCount = (real)$row->rfh_count; |
| 283 | + if( !$row->rfh_count ) continue; // bad data |
273 | 284 | // Nudge values up by 1 |
274 | 285 | $dayAve = 1 + (real)$row->rfh_total/(real)$row->rfh_count; |
275 | 286 | $cumAve = 1 + (real)$totalVal/(real)$totalCount; |
— | — | @@ -371,6 +382,7 @@ |
372 | 383 | $totalVal += (int)$row->rfh_total; |
373 | 384 | $totalCount += (int)$row->rfh_count; |
374 | 385 | $dayCount = (real)$row->rfh_count; |
| 386 | + if( !$row->rfh_count ) continue; // bad data |
375 | 387 | // Nudge values up by 1 to fit [1,5] |
376 | 388 | $dayAve = 1 + (real)$row->rfh_total/(real)$row->rfh_count; |
377 | 389 | $sd += pow($dayAve - $u,2); |
— | — | @@ -446,7 +458,7 @@ |
447 | 459 | </defs>'; |
448 | 460 | */ |
449 | 461 | # Create the graph |
450 | | - $plot->init(); |
| 462 | + @$plot->init(); |
451 | 463 | $plot->drawGraph(); |
452 | 464 | $plot->polyLine('dave'); |
453 | 465 | $plot->polyLine('rave'); |
— | — | @@ -607,13 +619,10 @@ |
608 | 620 | return $html; |
609 | 621 | } |
610 | 622 | |
611 | | - public function getVoteAggregates() { |
612 | | - if( $this->period > 93 ) { |
613 | | - return ''; // too big |
614 | | - } |
| 623 | + public function getVoteAggregates( $period ) { |
615 | 624 | // Set cutoff time for period |
616 | 625 | $dbr = wfGetDB( DB_SLAVE ); |
617 | | - $cutoff_unixtime = time() - ($this->period * 24 * 3600); |
| 626 | + $cutoff_unixtime = time() - ($period * 24 * 3600); |
618 | 627 | $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400); |
619 | 628 | $cutoff = $dbr->addQuotes( wfTimestamp( TS_MW, $cutoff_unixtime ) ); |
620 | 629 | // Get the first revision possibly voted on in the range |
— | — | @@ -649,19 +658,27 @@ |
650 | 659 | } |
651 | 660 | } |
652 | 661 | // Output multi-column list |
653 | | - $html = "<table class='fr_reader_feedback_stats'><tr>"; |
654 | | - $html .= '<tr><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th></tr>'; |
| 662 | + $html = "<table class='fr_reader_feedback_stats wikitable' cellspacing='0'><tr>"; |
| 663 | + foreach( FlaggedRevs::getFeedbackTags() as $tag => $w ) { |
| 664 | + $html .= '<th>'.wfMsgHtml("readerfeedback-$tag").'</th>'; |
| 665 | + } |
| 666 | + $html .= '</tr><tr>'; |
655 | 667 | foreach( $votes as $tag => $dist ) { |
656 | | - $html .= '<tr>'; |
657 | | - $html .= '<td>'.wfMsgHtml("readerfeedback-$tag") . '</td>'; |
| 668 | + $html .= '<td><table>'; |
| 669 | + $html .= '<tr><th align="left">'.wfMsgHtml('ratinghistory-table-rating').'</th>'; |
| 670 | + for( $i = 1; $i <= 5; $i++ ) { |
| 671 | + $html .= "<td class='fr-rating-option-".($i-1)."'>$i</td>"; |
| 672 | + } |
| 673 | + $html .= '</tr><tr>'; |
| 674 | + $html .= '<th align="left">'.wfMsgHtml("ratinghistory-table-votes").'</th>'; |
658 | 675 | $html .= '<td>'.$dist[0].'</td>'; |
659 | 676 | $html .= '<td>'.$dist[1].'</td>'; |
660 | 677 | $html .= '<td>'.$dist[2].'</td>'; |
661 | 678 | $html .= '<td>'.$dist[3].'</td>'; |
662 | 679 | $html .= '<td>'.$dist[4].'</td>'; |
663 | | - $html .= "</tr>\n"; |
| 680 | + $html .= "</tr></table></td>\n"; |
664 | 681 | } |
665 | | - $html .= "</tr></table>\n"; |
| 682 | + $html .= '</tr></table>'; |
666 | 683 | return $html; |
667 | 684 | } |
668 | 685 | |