Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc |
— | — | @@ -216,25 +216,6 @@ |
217 | 217 | $key = wfMemcKey( 'flaggedrevs', 'reviewPercentiles' ); |
218 | 218 | $dbCache = wfGetCache( CACHE_DB ); |
219 | 219 | $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 ); |
239 | 220 | // Save the data |
240 | 221 | $dbw = wfGetDB( DB_MASTER ); |
241 | 222 | $dbw->begin(); |
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php |
— | — | @@ -119,8 +119,7 @@ |
120 | 120 | } |
121 | 121 | $wgOut->addHTML( Xml::closeElement( 'table' ) ); |
122 | 122 | |
123 | | - $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' ); |
124 | | - $data = $dbCache->get( $key ); |
| 123 | + $data = $this->getTopFiveReviewers(); |
125 | 124 | # Is there a top 5 user list? |
126 | 125 | if( is_array($data) && count($data) ) { |
127 | 126 | $wgOut->addWikiMsg( 'validationstatistics-utable' ); |
— | — | @@ -202,4 +201,32 @@ |
203 | 202 | $val = $this->db->selectField( 'flaggedrevs_stats2', 'ave_pending_time' ); |
204 | 203 | return ($val == false ? '-' : $val ); |
205 | 204 | } |
| 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 | + } |
206 | 233 | } |