Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -193,6 +193,12 @@ |
194 | 194 | # Set to false to disable (perhaps using a cron job instead). |
195 | 195 | $wgFlaggedRevsStatsAge = 2 * 3600; // 2 hours |
196 | 196 | |
| 197 | +# Configurable information to collect and display at Special:ValidationStatistics |
| 198 | +$wgFlaggedRevsStats = array( |
| 199 | + 'topReviewersCount' => 5, # how many top reviewers to list |
| 200 | + 'topReviewersHours' => 1, # how many hours of the last reviews to count |
| 201 | +); |
| 202 | + |
197 | 203 | # How to handle templates and files used in stable versions: |
198 | 204 | # FR_INCLUDES_CURRENT |
199 | 205 | # Always use the current version of templates/files |
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | 'validationstatistics-latest' => 'Synced', |
28 | 28 | 'validationstatistics-synced' => 'Synced/Reviewed', |
29 | 29 | 'validationstatistics-old' => 'Outdated', |
30 | | - 'validationstatistics-utable' => 'Below is a list of the {{PLURAL:$1|most active reviewer|$1 most active reviewers}} in the last hour.', |
| 30 | + 'validationstatistics-utable' => 'Below is a list of the {{PLURAL:$1|most active reviewer|$1 most active reviewers}} in the last {{PLURAL:$2|hour|$2 hours}}.', |
31 | 31 | 'validationstatistics-user' => 'User', |
32 | 32 | 'validationstatistics-reviews' => 'Reviews', |
33 | 33 | ); |
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function execute( $par ) { |
15 | | - global $wgUser, $wgOut, $wgLang, $wgContLang; |
| 15 | + global $wgUser, $wgOut, $wgLang, $wgContLang, $wgFlaggedRevsStats; |
16 | 16 | $this->setHeaders(); |
17 | 17 | $this->skin = $wgUser->getSkin(); |
18 | 18 | $this->db = wfGetDB( DB_SLAVE ); |
— | — | @@ -146,12 +146,15 @@ |
147 | 147 | ); |
148 | 148 | } |
149 | 149 | $wgOut->addHTML( Xml::closeElement( 'table' ) ); |
150 | | - # Is there a top 5 user list? If so, then show it... |
151 | | - $data = $this->getTopFiveReviewers(); |
| 150 | + # Is there a top X user list? If so, then show it... |
| 151 | + $data = $this->getTopReviewers(); |
152 | 152 | if ( is_array( $data ) && count( $data ) ) { |
153 | | - $wgOut->addWikiMsg( 'validationstatistics-utable', $wgLang->formatNum( 5 ) ); |
154 | | - |
155 | | - $reviewChart = "<table class='wikitable flaggedrevs_stats_table' style='white-space: nowrap;'>\n"; |
| 153 | + $wgOut->addWikiMsg( 'validationstatistics-utable', |
| 154 | + $wgLang->formatNum( $wgFlaggedRevsStats['topReviewersCount'] ), |
| 155 | + $wgLang->formatNum( $wgFlaggedRevsStats['topReviewersHours'] ) |
| 156 | + ); |
| 157 | + $css = 'wikitable flaggedrevs_stats_table'; |
| 158 | + $reviewChart = "<table class='$css' style='white-space: nowrap;'>\n"; |
156 | 159 | $reviewChart .= '<tr><th>' . wfMsgHtml( 'validationstatistics-user' ) . |
157 | 160 | '</th><th>' . wfMsgHtml( 'validationstatistics-reviews' ) . '</th></tr>'; |
158 | 161 | foreach ( $data as $userId => $reviews ) { |
— | — | @@ -236,24 +239,31 @@ |
237 | 240 | return ( $val == false ? '-' : $val ); |
238 | 241 | } |
239 | 242 | |
240 | | - protected function getTopFiveReviewers() { |
| 243 | + // top X reviewers in the last Y hours |
| 244 | + protected function getTopReviewers() { |
| 245 | + global $wgFlaggedRevsStats; |
| 246 | + |
241 | 247 | $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' ); |
242 | 248 | $dbCache = wfGetCache( CACHE_DB ); |
243 | 249 | $data = $dbCache->get( $key ); |
244 | | - if ( is_array( $data ) ) |
| 250 | + if ( is_array( $data ) ) { |
245 | 251 | return $data; // cache hit |
| 252 | + } |
| 253 | + $limit = (int)$wgFlaggedRevsStats['topReviewersCount']; |
| 254 | + $seconds = 3600*$wgFlaggedRevsStats['topReviewersHours']; |
246 | 255 | |
247 | 256 | $dbr = wfGetDB( DB_SLAVE ); |
248 | | - $cutoff = $dbr->timestamp( time() - 3600 ); |
| 257 | + $cutoff = $dbr->timestamp( time() - $seconds ); |
249 | 258 | $res = $dbr->select( 'logging', |
250 | 259 | array( 'log_user', 'COUNT(*) AS reviews' ), |
251 | 260 | array( |
252 | 261 | 'log_type' => 'review', // page reviews |
253 | | - 'log_action' => array( 'approve', 'approve2', 'approve-i', 'approve2-i' ), // manual approvals |
| 262 | + // manual approvals (filter on log_action) |
| 263 | + 'log_action' => array( 'approve', 'approve2', 'approve-i', 'approve2-i' ), |
254 | 264 | 'log_timestamp >= ' . $dbr->addQuotes( $cutoff ) // last hour |
255 | 265 | ), |
256 | 266 | __METHOD__, |
257 | | - array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => 5 ) |
| 267 | + array( 'GROUP BY' => 'log_user', 'ORDER BY' => 'reviews DESC', 'LIMIT' => $limit ) |
258 | 268 | ); |
259 | 269 | $data = array(); |
260 | 270 | foreach ( $res as $row ) { |