r55126 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55125‎ | r55126 | r55127 >
Date:07:05, 16 August 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Less vague error messages
* Made review count a solid line for png files too
* Use per-graph reviews/day scale to fit to graph
Modified paths:
  • /trunk/extensions/ReaderFeedback/language/RatingHistory.i18n.php (modified) (history)
  • /trunk/extensions/ReaderFeedback/specialpages/RatingHistory_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReaderFeedback/specialpages/RatingHistory_body.php
@@ -141,7 +141,8 @@
142142 Xml::openElement( 'div', array('class' => 'rfb-reader_feedback_graph') ) .
143143 Xml::element( 'embed', array('src' => $url, 'type' => 'image/svg+xml',
144144 'class' => 'rfb-reader_feedback_plot', 'width' => '1000', 'height' => '410') ) .
145 - Xml::closeElement( 'div' ) . "\n";
 145+ Xml::closeElement( 'div' ) . "\n" .
 146+ wfMsgExt('ratinghistory-graph-scale', 'parse', $this->dScale ) . "\n";
146147 }
147148 break;
148149 case 'png':
@@ -157,7 +158,8 @@
158159 Xml::openElement( 'div', array('class' => 'rfb-reader_feedback_graph') ) .
159160 Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) .
160161 Xml::closeElement( 'img' ) .
161 - Xml::closeElement( 'div' ) . "\n";
 162+ Xml::closeElement( 'div' ) . "\n" .
 163+ wfMsgExt('ratinghistory-graph-scale', 'parse', $this->dScale ) . "\n";
162164 }
163165 break;
164166 default: // use html table
@@ -181,7 +183,7 @@
182184 $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-chart') . "$purgeLink</h2>\n" );
183185 if( $data ) {
184186 // Add legend as needed
185 - $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) );
 187+ $wgOut->addWikiText( wfMsg('ratinghistory-legend') );
186188 // Add recent voter list
187189 $userTable = $this->getUserList();
188190 if( $userTable ) {
@@ -254,7 +256,7 @@
255257 // GD is not installed
256258 return false;
257259 }
258 - global $wgPHPlotDir;
 260+ global $wgPHPlotDir, $wgMemc;
259261 require_once( "$wgPHPlotDir/phplot.php" ); // load classes
260262 // Define the object
261263 $plot = new PHPlot( 1000, 400 );
@@ -312,6 +314,11 @@
313315 if( count($data) < 2 ) {
314316 return false;
315317 }
 318+ // Re-scale voter count to fit to graph
 319+ $this->dScale = ceil($maxC/5);
 320+ // Cache the scale value to memory
 321+ $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
 322+ $wgMemc->set( $key, $this->dScale, 7*24*3600 );
316323 // Fit to [0,4]
317324 foreach( $data as $x => $dataRow ) {
318325 $data[$x][3] = $dataRow[3]/$this->dScale;
@@ -320,7 +327,7 @@
321328 $plot->SetPointShapes( array('dot','dot','dot') );
322329 $plot->setPointSizes( array(1,1,4) );
323330 $plot->SetDataColors( array('blue','green','red') );
324 - $plot->SetLineStyles( array('solid','solid','none') );
 331+ $plot->SetLineStyles( array('solid','solid','solid') );
325332 $plot->SetBackgroundColor('#F8F8F8');
326333 // Turn off X axis ticks and labels because they get in the way:
327334 $plot->SetXTickLabelPos('none');
@@ -426,6 +433,11 @@
427434 // Round values for display
428435 $sd = round( $sd, 3 );
429436 $u = round( $u, 3 );
 437+ // Re-scale voter count to fit to graph
 438+ $this->dScale = ceil($maxC/5);
 439+ // Cache the scale value to memory
 440+ $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
 441+ $wgMemc->set( $key, $this->dScale, 7*24*3600 );
430442 // Fit to [0,4]
431443 foreach( $dcount as $x => $c ) {
432444 $dcount[$x] = $c/$this->dScale;
@@ -475,7 +487,7 @@
476488 // Rasterize due to IE suckage
477489 $status = $svgHandler->rasterize( $svgPath, $filePath, 1000, 410 );
478490 if( $status !== true ) {
479 - throw new MWException( 'Could not write SVG file!' );
 491+ throw new MWException( 'Could not rasterize SVG file!' );
480492 return false;
481493 }
482494 return true;
@@ -658,15 +670,22 @@
659671 }
660672
661673 /**
662 - * Check if a graph file is expired.
 674+ * Check if a graph file is expired. Set $this->dScale.
663675 * @param string $tag
664676 * @param string $path, filepath to existing file
665677 * @returns string
666678 */
667679 protected function fileExpired( $tag, $path ) {
 680+ global $wgMemc;
668681 if( $this->doPurge || !file_exists($path) ) {
669682 return true;
670683 }
 684+ $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
 685+ // Get scale cache value...
 686+ $this->dScale = $wgMemc->get( $key );
 687+ if( $this->dScale == false ) {
 688+ return true;
 689+ }
671690 $dbr = wfGetDB( DB_SLAVE );
672691 $tagTimestamp = $dbr->selectField( 'reader_feedback_pages', 'rfp_touched',
673692 array( 'rfp_page_id' => $this->page->getArticleId(), 'rfp_tag' => $tag ),
Index: trunk/extensions/ReaderFeedback/language/RatingHistory.i18n.php
@@ -34,7 +34,8 @@
3535
3636 Scale: \'\'\'[1]\'\'\' - Poor; \'\'\'[2]\'\'\' - Low; \'\'\'[3]\'\'\' - Fair; \'\'\'[4]\'\'\' - High; \'\'\'[5]\'\'\' - Excellent;
3737
38 - The \'\'\'number of reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> is shown on the graphs below, on a \'\'1:$1\'\' scale.',
 38+ The \'\'\'number of reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> is shown on the graphs below; the scale is given for each graph.',
 39+ 'ratinghistory-graph-scale' => '\'\'\'Reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> shown on a \'\'1:$1\'\' scale.',
3940 'right-feedback' => 'Use the feedback form to rate a page',
4041 );
4142

Follow-up revisions

RevisionCommit summaryAuthorDate
r55127missing global dec from r55126aaron07:07, 16 August 2009

Status & tagging log