r47646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47645‎ | r47646 | r47647 >
Date:03:51, 22 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Added percentile table and made median use same general formula
* Stylistic tweaks
* Removed unused global
Modified paths:
  • /trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateStats.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc
@@ -188,8 +188,9 @@
189189 while( $row = $dbr->fetchObject($res) ) {
190190 # Reviewed: just subtract the times
191191 if( $row->ft ) {
192 - $seconds += ($row->ft - $row->rt);
193 - $times[] = ($row->ft - $row->rt);
 192+ $time = $row->ft - $row->rt;
 193+ $seconds += $time;
 194+ $times[] = $time;
194195 # Not reviewed: censored data
195196 } else {
196197 $seconds += ($now - $row->rt);
@@ -200,11 +201,19 @@
201202 $aveRT = $seconds/($count - $censored); // sample mean
202203 sort($times); // order smallest -> largest
203204 // Sample median
204 - if( count($times) % 2 == 0 ) {
205 - $medianRT = ($times[count($times)/2-1] + $times[count($times)/2])/2;
206 - } else {
207 - $medianRT = $times[floor(count($times)/2)];
 205+ $rank = round( count($times)/2 + .5 ) - 1;
 206+ $medianRT = $times[$rank];
 207+ // Make percentile tabulation data
 208+ $data = array();
 209+ $percentile = 30; // start at 30th
 210+ while( $percentile < 100 ) {
 211+ $rank = round( $percentile*count($times)/100 + .5 ) - 1;
 212+ $data[$percentile] = $times[$rank];
 213+ $percentile += 10;
208214 }
 215+ $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' );
 216+ $dbCache = wfGetCache( CACHE_DB );
 217+ $dbCache->set( $key, $data, 30*24*3600 );
209218 }
210219 // Save the data
211220 $dbw = wfGetDB( DB_MASTER );
@@ -239,6 +248,7 @@
240249 print( "done updating!\n" );
241250 }
242251
 252+// Per-Namespace stats
243253 function createFlaggedRevsStatsTable( $dbw, $flaggedrevs_stats ) {
244254 $dbw->query(
245255 "CREATE TABLE $flaggedrevs_stats (
@@ -250,6 +260,7 @@
251261 );
252262 }
253263
 264+// General stats
254265 function createFlaggedRevsStatsTable2( $dbw, $flaggedrevs_stats2 ) {
255266 $dbw->query(
256267 "CREATE TABLE $flaggedrevs_stats2 (
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php
@@ -12,7 +12,7 @@
1313 'validationstatistics-users' => '\'\'\'{{SITENAME}}\'\'\' currently has \'\'\'[[Special:ListUsers/editor|$1]]\'\'\' {{PLURAL:$1|user|users}} with [[{{MediaWiki:Validationpage}}|Editor]] rights
1414 and \'\'\'[[Special:ListUsers/reviewer|$2]]\'\'\' {{PLURAL:$2|user|users}} with [[{{MediaWiki:Validationpage}}|Reviewer]] rights.',
1515 'validationstatistics-time' => 'The average wait for edits by \'\'users that have not logged in\'\' is \'\'\'$1\'\'\'; the median is \'\'\'$3\'\'\'.
16 -
 16+$4
1717 The average lag for [[Special:OldReviewedPages|pages with unreviewed edits pending]] is \'\'\'$2\'\'\'.',
1818 'validationstatistics-table' => "Statistics for each namespace are shown below, ''excluding'' redirect pages.
1919 ''Outdated'' pages are those with edits newer than the stable version.
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php
@@ -13,7 +13,7 @@
1414 }
1515
1616 public function execute( $par ) {
17 - global $wgRequest, $wgUser, $wgOut, $wgLang, $wgContLang, $wgFlaggedRevsNamespaces;
 17+ global $wgUser, $wgOut, $wgLang, $wgContLang;
1818 $this->setHeaders();
1919 $this->skin = $wgUser->getSkin();
2020 $this->db = wfGetDB( DB_SLAVE );
@@ -29,14 +29,35 @@
3030 $wgOut->addWikiText( wfMsgExt( 'validationstatistics-users', array( 'parsemag' ),
3131 $wgLang->formatnum($ec), $wgLang->formatnum($rc) )
3232 );
33 - $wgOut->addWikiText( wfMsgExt( 'validationstatistics-time', array( 'parsemag' ),
34 - $wgLang->formatTimePeriod($mt), $wgLang->formatTimePeriod($pt), $wgLang->formatTimePeriod($mdt) )
35 - );
36 -
 33+ # Most of the output depends on background queries
3734 if( !$this->readyForQuery() ) {
3835 return false;
3936 }
4037
 38+ $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' );
 39+ $dbCache = wfGetCache( CACHE_DB );
 40+ $data = $dbCache->get( $key );
 41+ # Is there a review time table available?
 42+ if( is_array($data) ) {
 43+ $headerRows = $dataRows = '';
 44+ foreach( $data as $percentile => $perValue ) {
 45+ $headerRows .= "<th>P<sub>$percentile</sub></th>";
 46+ $dataRows .= '<td>'.$wgLang->formatTimePeriod($perValue).'</td>';
 47+ }
 48+ $reviewChart = "<table class='wikitable flaggedrevs_stats_table' style='white-space: nowrap;'>\n";
 49+ $reviewChart .= "<tr align='center'>$headerRows</tr>\n";
 50+ $reviewChart .= "<tr align='center'>$dataRows</tr>\n";
 51+ $reviewChart .= "</table>\n";
 52+ } else {
 53+ $reviewChart = '';
 54+ }
 55+
 56+ # Show review/pending time stats
 57+ $wgOut->addWikiText( wfMsgExt( 'validationstatistics-time', array( 'parsemag' ),
 58+ $wgLang->formatTimePeriod($mt), $wgLang->formatTimePeriod($pt),
 59+ $wgLang->formatTimePeriod($mdt), $reviewChart )
 60+ );
 61+
4162 $wgOut->addWikiText( '<hr/>' . wfMsg('validationstatistics-table') );
4263 $wgOut->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable flaggedrevs_stats_table' ) ) );
4364 $wgOut->addHTML( "<tr>\n" );
@@ -49,6 +70,7 @@
5071 }
5172 $wgOut->addHTML( "</tr>\n" );
5273
 74+ global $wgFlaggedRevsNamespaces;
5375 foreach( $wgFlaggedRevsNamespaces as $namespace ) {
5476 $row = $this->db->selectRow( 'flaggedrevs_stats', '*', array('namespace' => $namespace) );
5577 $NsText = $wgContLang->getFormattedNsText( $row->namespace );

Status & tagging log