Revision: 46004
Author: aaron
Date: 2009-01-22 05:52:37 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
* Pretty up quick table overview
* Added table to ratinghistory
* Division by zero notice fixes
Modified Paths:
--------------
trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php
trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
Modified: trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php
===================================================================
--- trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php
2009-01-22 05:10:18 UTC (rev 46003)
+++ trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php
2009-01-22 05:52:37 UTC (rev 46004)
@@ -19,9 +19,12 @@
'ratinghistory-year' => 'last year',
'ratinghistory-3years' => 'last 3 years',
'ratinghistory-chart' => 'Reader feedback rating over time',
+ 'ratinghistory-table' => 'Overview of last month',
'ratinghistory-users' => 'Users who gave ratings',
'ratinghistory-graph' => '$2 of "$3" ($1
{{PLURAL:$1|review|reviews}})',
'readerfeedback-svg' => 'View as SVG',
+ 'ratinghistory-table-rating' => 'Rating',
+ 'ratinghistory-table-votes' => 'Votes',
'ratinghistory-none' => 'There is not enough reader feedback data
available for graphs at this time.',
'ratinghistory-legend' => 'The \'\'\'daily average rating\'\'\' <font
color="blue">\'\'(blue)\'\'</font> and
\'\'\'running average rating\'\'\' <font
color="green">\'\'(green)\'\'</font> are graphed below, by date. The
Modified: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
===================================================================
--- trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
2009-01-22 05:10:18 UTC (rev 46003)
+++ trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
2009-01-22 05:52:37 UTC (rev 46004)
@@ -63,9 +63,19 @@
} else {
$wgOut->enableClientCache( false ); // don't show stale
graphs
}
+ $this->showTable();
$this->showGraphs();
}
+ protected function showTable() {
+ global $wgOut;
+ # Show latest month of results
+ $html = $this->getVoteAggregates( 31 );
+ if( $html ) {
+ $wgOut->addHTML(
'<h2>'.wfMsgHtml('ratinghistory-table')."</h2>\n".$html );
+ }
+ }
+
protected function showHeader() {
global $wgOut;
$wgOut->addWikiText(
wfMsg('ratinghistory-legend',$this->dScale) );
@@ -269,6 +279,7 @@
$totalVal += (int)$row->rfh_total;
$totalCount += (int)$row->rfh_count;
$dayCount = (real)$row->rfh_count;
+ if( !$row->rfh_count ) continue; // bad data
// Nudge values up by 1
$dayAve = 1 +
(real)$row->rfh_total/(real)$row->rfh_count;
$cumAve = 1 + (real)$totalVal/(real)$totalCount;
@@ -371,6 +382,7 @@
$totalVal += (int)$row->rfh_total;
$totalCount += (int)$row->rfh_count;
$dayCount = (real)$row->rfh_count;
+ if( !$row->rfh_count ) continue; // bad data
// Nudge values up by 1 to fit [1,5]
$dayAve = 1 +
(real)$row->rfh_total/(real)$row->rfh_count;
$sd += pow($dayAve - $u,2);
@@ -446,7 +458,7 @@
</defs>';
*/
# Create the graph
- $plot->init();
+ @$plot->init();
$plot->drawGraph();
$plot->polyLine('dave');
$plot->polyLine('rave');
@@ -607,13 +619,10 @@
return $html;
}
- public function getVoteAggregates() {
- if( $this->period > 93 ) {
- return ''; // too big
- }
+ public function getVoteAggregates( $period ) {
// Set cutoff time for period
$dbr = wfGetDB( DB_SLAVE );
- $cutoff_unixtime = time() - ($this->period * 24 * 3600);
+ $cutoff_unixtime = time() - ($period * 24 * 3600);
$cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime %
86400);
$cutoff = $dbr->addQuotes( wfTimestamp( TS_MW, $cutoff_unixtime
) );
// Get the first revision possibly voted on in the range
@@ -649,19 +658,27 @@
}
}
// Output multi-column list
- $html = "<table class='fr_reader_feedback_stats'><tr>";
- $html .=
'<tr><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th></tr>';
+ $html = "<table class='fr_reader_feedback_stats wikitable'
cellspacing='0'><tr>";
+ foreach( FlaggedRevs::getFeedbackTags() as $tag => $w ) {
+ $html .=
'<th>'.wfMsgHtml("readerfeedback-$tag").'</th>';
+ }
+ $html .= '</tr><tr>';
foreach( $votes as $tag => $dist ) {
- $html .= '<tr>';
- $html .= '<td>'.wfMsgHtml("readerfeedback-$tag") .
'</td>';
+ $html .= '<td><table>';
+ $html .= '<tr><th
align="left">'.wfMsgHtml('ratinghistory-table-rating').'</th>';
+ for( $i = 1; $i <= 5; $i++ ) {
+ $html .= "<td
class='fr-rating-option-".($i-1)."'>$i</td>";
+ }
+ $html .= '</tr><tr>';
+ $html .= '<th
align="left">'.wfMsgHtml("ratinghistory-table-votes").'</th>';
$html .= '<td>'.$dist[0].'</td>';
$html .= '<td>'.$dist[1].'</td>';
$html .= '<td>'.$dist[2].'</td>';
$html .= '<td>'.$dist[3].'</td>';
$html .= '<td>'.$dist[4].'</td>';
- $html .= "</tr>\n";
+ $html .= "</tr></table></td>\n";
}
- $html .= "</tr></table>\n";
+ $html .= '</tr></table>';
return $html;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs