r51629 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51628‎ | r51629 | r51630 >
Date:02:02, 9 June 2009
Author:aaron
Status:ok
Tags:
Comment:
Tweaked r51626: make sure list is reasonably up to date
Modified paths:
  • /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
@@ -216,25 +216,6 @@
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 );
239220 // Save the data
240221 $dbw = wfGetDB( DB_MASTER );
241222 $dbw->begin();
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php
@@ -119,8 +119,7 @@
120120 }
121121 $wgOut->addHTML( Xml::closeElement( 'table' ) );
122122
123 - $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
124 - $data = $dbCache->get( $key );
 123+ $data = $this->getTopFiveReviewers();
125124 # Is there a top 5 user list?
126125 if( is_array($data) && count($data) ) {
127126 $wgOut->addWikiMsg( 'validationstatistics-utable' );
@@ -202,4 +201,32 @@
203202 $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_pending_time' );
204203 return ($val == false ? '-' : $val );
205204 }
 205+
 206+ protected function getTopFiveReviewers() {
 207+ $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
 208+ $dbCache = wfGetCache( CACHE_DB );
 209+ $data = $dbCache->get( $key );
 210+ if( is_array($data) )
 211+ return $data; // cache hit
 212+
 213+ $dbr = wfGetDB( DB_SLAVE );
 214+ $cutoff = $dbr->timestamp( time() - 3600 );
 215+ $res = $dbr->select( 'logging',
 216+ array('log_user','COUNT(*) AS reviews'),
 217+ array(
 218+ 'log_type' => 'review', // page reviews
 219+ 'log_action' => array('approve','approve2','approve-i','approve2-i'), // manual approvals
 220+ 'log_timestamp >= '.$dbr->addQuotes( $cutoff ) // last hour
 221+ ),
 222+ __METHOD__,
 223+ array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => 5 )
 224+ );
 225+ $data = array();
 226+ foreach( $res as $row ) {
 227+ $data[$row->log_user] = $row->reviews;
 228+ }
 229+ // Save/cache users
 230+ $dbCache->set( $key, $data, 3600 );
 231+ return $data;
 232+ }
206233 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51626*Addded top 5 reviewer list...aaron01:31, 9 June 2009

Status & tagging log