r51626 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51625‎ | r51626 | r51627 >
Date:01:31, 9 June 2009
Author:aaron
Status:ok
Tags:
Comment:
*Addded top 5 reviewer list
*XHTML
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
@@ -212,10 +212,29 @@
213213 $percentile += 10;
214214 }
215215 }
216 - // Cache percentiles
 216+ // Save/cache percentiles
217217 $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' );
218218 $dbCache = wfGetCache( CACHE_DB );
219219 $dbCache->set( $key, $data, 30*24*3600 );
 220+ // Get the top reviewer list
 221+ $cutoff = $dbr->timestamp( time() - 3600 );
 222+ $res = $dbr->select( 'logging',
 223+ array('log_user','COUNT(*) AS reviews'),
 224+ array(
 225+ 'log_type' => 'review', // page reviews
 226+ 'log_action' => array('approve','approve2','approve-i','approve2-i'), // manual approvals
 227+ 'log_timestamp >= '.$dbr->addQuotes( $cutoff ) // last hour
 228+ ),
 229+ __METHOD__,
 230+ array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => 5 )
 231+ );
 232+ $data = array();
 233+ foreach( $res as $row ) {
 234+ $data[$row->log_user] = $row->reviews;
 235+ }
 236+ // Save/cache users
 237+ $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
 238+ $dbCache->set( $key, $data, 30*24*3600 );
220239 // Save the data
221240 $dbw = wfGetDB( DB_MASTER );
222241 $dbw->begin();
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php
@@ -29,6 +29,9 @@
3030 'validationstatistics-latest' => 'Synced',
3131 'validationstatistics-synced' => 'Synced/Reviewed',
3232 'validationstatistics-old' => 'Outdated',
 33+ 'validationstatistics-utable' => 'Below is the list of top 5 reviewers in the last hour.',
 34+ 'validationstatistics-user' => 'User',
 35+ 'validationstatistics-reviews' => 'Reviews',
3336 );
3437
3538 /** Message documentation (Message documentation)
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php
@@ -38,7 +38,7 @@
3939 $dbCache = wfGetCache( CACHE_DB );
4040 $data = $dbCache->get( $key );
4141 # Is there a review time table available?
42 - if( is_array($data) ) {
 42+ if( is_array($data) && count($data) ) {
4343 $headerRows = $dataRows = '';
4444 foreach( $data as $percentile => $perValue ) {
4545 $headerRows .= "<th>P<sub>".intval($percentile)."</sub></th>";
@@ -118,6 +118,23 @@
119119 );
120120 }
121121 $wgOut->addHTML( Xml::closeElement( 'table' ) );
 122+
 123+ $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
 124+ $data = $dbCache->get( $key );
 125+ # Is there a top 5 user list?
 126+ if( is_array($data) && count($data) ) {
 127+ $wgOut->addWikiMsg( 'validationstatistics-utable' );
 128+
 129+ $reviewChart = "<table class='wikitable flaggedrevs_stats_table' style='white-space: nowrap;'>\n";
 130+ $reviewChart .= '<tr><th>'.wfMsgHtml('validationstatistics-user').
 131+ '</th><th>'.wfMsgHtml('validationstatistics-reviews').'</th></tr>';
 132+ foreach( $data as $userId => $reviews ) {
 133+ $reviewChart .= '<tr><td>'.htmlspecialchars(User::whois($userId)).
 134+ '</td><td>'.intval($reviews).'</td></tr>';
 135+ }
 136+ $reviewChart .= "</table>\n";
 137+ $wgOut->addHTML( $reviewChart );
 138+ }
122139 }
123140
124141 protected function maybeUpdate() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r51629Tweaked r51626: make sure list is reasonably up to dateaaron02:02, 9 June 2009

Status & tagging log