Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc |
— | — | @@ -188,8 +188,9 @@ |
189 | 189 | while( $row = $dbr->fetchObject($res) ) { |
190 | 190 | # Reviewed: just subtract the times |
191 | 191 | 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; |
194 | 195 | # Not reviewed: censored data |
195 | 196 | } else { |
196 | 197 | $seconds += ($now - $row->rt); |
— | — | @@ -200,11 +201,19 @@ |
201 | 202 | $aveRT = $seconds/($count - $censored); // sample mean |
202 | 203 | sort($times); // order smallest -> largest |
203 | 204 | // 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; |
208 | 214 | } |
| 215 | + $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' ); |
| 216 | + $dbCache = wfGetCache( CACHE_DB ); |
| 217 | + $dbCache->set( $key, $data, 30*24*3600 ); |
209 | 218 | } |
210 | 219 | // Save the data |
211 | 220 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -239,6 +248,7 @@ |
240 | 249 | print( "done updating!\n" ); |
241 | 250 | } |
242 | 251 | |
| 252 | +// Per-Namespace stats |
243 | 253 | function createFlaggedRevsStatsTable( $dbw, $flaggedrevs_stats ) { |
244 | 254 | $dbw->query( |
245 | 255 | "CREATE TABLE $flaggedrevs_stats ( |
— | — | @@ -250,6 +260,7 @@ |
251 | 261 | ); |
252 | 262 | } |
253 | 263 | |
| 264 | +// General stats |
254 | 265 | function createFlaggedRevsStatsTable2( $dbw, $flaggedrevs_stats2 ) { |
255 | 266 | $dbw->query( |
256 | 267 | "CREATE TABLE $flaggedrevs_stats2 ( |
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | 'validationstatistics-users' => '\'\'\'{{SITENAME}}\'\'\' currently has \'\'\'[[Special:ListUsers/editor|$1]]\'\'\' {{PLURAL:$1|user|users}} with [[{{MediaWiki:Validationpage}}|Editor]] rights |
14 | 14 | and \'\'\'[[Special:ListUsers/reviewer|$2]]\'\'\' {{PLURAL:$2|user|users}} with [[{{MediaWiki:Validationpage}}|Reviewer]] rights.', |
15 | 15 | 'validationstatistics-time' => 'The average wait for edits by \'\'users that have not logged in\'\' is \'\'\'$1\'\'\'; the median is \'\'\'$3\'\'\'. |
16 | | - |
| 16 | +$4 |
17 | 17 | The average lag for [[Special:OldReviewedPages|pages with unreviewed edits pending]] is \'\'\'$2\'\'\'.', |
18 | 18 | 'validationstatistics-table' => "Statistics for each namespace are shown below, ''excluding'' redirect pages. |
19 | 19 | ''Outdated'' pages are those with edits newer than the stable version. |
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function execute( $par ) { |
17 | | - global $wgRequest, $wgUser, $wgOut, $wgLang, $wgContLang, $wgFlaggedRevsNamespaces; |
| 17 | + global $wgUser, $wgOut, $wgLang, $wgContLang; |
18 | 18 | $this->setHeaders(); |
19 | 19 | $this->skin = $wgUser->getSkin(); |
20 | 20 | $this->db = wfGetDB( DB_SLAVE ); |
— | — | @@ -29,14 +29,35 @@ |
30 | 30 | $wgOut->addWikiText( wfMsgExt( 'validationstatistics-users', array( 'parsemag' ), |
31 | 31 | $wgLang->formatnum($ec), $wgLang->formatnum($rc) ) |
32 | 32 | ); |
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 |
37 | 34 | if( !$this->readyForQuery() ) { |
38 | 35 | return false; |
39 | 36 | } |
40 | 37 | |
| 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 | + |
41 | 62 | $wgOut->addWikiText( '<hr/>' . wfMsg('validationstatistics-table') ); |
42 | 63 | $wgOut->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable flaggedrevs_stats_table' ) ) ); |
43 | 64 | $wgOut->addHTML( "<tr>\n" ); |
— | — | @@ -49,6 +70,7 @@ |
50 | 71 | } |
51 | 72 | $wgOut->addHTML( "</tr>\n" ); |
52 | 73 | |
| 74 | + global $wgFlaggedRevsNamespaces; |
53 | 75 | foreach( $wgFlaggedRevsNamespaces as $namespace ) { |
54 | 76 | $row = $this->db->selectRow( 'flaggedrevs_stats', '*', array('namespace' => $namespace) ); |
55 | 77 | $NsText = $wgContLang->getFormattedNsText( $row->namespace ); |