Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc |
— | — | @@ -212,10 +212,29 @@ |
213 | 213 | $percentile += 10; |
214 | 214 | } |
215 | 215 | } |
216 | | - // Cache percentiles |
| 216 | + // Save/cache percentiles |
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 ); |
220 | 239 | // Save the data |
221 | 240 | $dbw = wfGetDB( DB_MASTER ); |
222 | 241 | $dbw->begin(); |
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php |
— | — | @@ -29,6 +29,9 @@ |
30 | 30 | 'validationstatistics-latest' => 'Synced', |
31 | 31 | 'validationstatistics-synced' => 'Synced/Reviewed', |
32 | 32 | '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', |
33 | 36 | ); |
34 | 37 | |
35 | 38 | /** Message documentation (Message documentation) |
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | $dbCache = wfGetCache( CACHE_DB ); |
40 | 40 | $data = $dbCache->get( $key ); |
41 | 41 | # Is there a review time table available? |
42 | | - if( is_array($data) ) { |
| 42 | + if( is_array($data) && count($data) ) { |
43 | 43 | $headerRows = $dataRows = ''; |
44 | 44 | foreach( $data as $percentile => $perValue ) { |
45 | 45 | $headerRows .= "<th>P<sub>".intval($percentile)."</sub></th>"; |
— | — | @@ -118,6 +118,23 @@ |
119 | 119 | ); |
120 | 120 | } |
121 | 121 | $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 | + } |
122 | 139 | } |
123 | 140 | |
124 | 141 | protected function maybeUpdate() { |