r84198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84197‎ | r84198 | r84199 >
Date:19:33, 17 March 2011
Author:aaron
Status:ok
Tags:
Comment:
(bug 26268) Made TopFiveReviewers configurable
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -193,6 +193,12 @@
194194 # Set to false to disable (perhaps using a cron job instead).
195195 $wgFlaggedRevsStatsAge = 2 * 3600; // 2 hours
196196
 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+
197203 # How to handle templates and files used in stable versions:
198204 # FR_INCLUDES_CURRENT
199205 # Always use the current version of templates/files
Index: trunk/extensions/FlaggedRevs/language/ValidationStatistics.i18n.php
@@ -26,7 +26,7 @@
2727 'validationstatistics-latest' => 'Synced',
2828 'validationstatistics-synced' => 'Synced/Reviewed',
2929 '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}}.',
3131 'validationstatistics-user' => 'User',
3232 'validationstatistics-reviews' => 'Reviews',
3333 );
Index: trunk/extensions/FlaggedRevs/specialpages/ValidationStatistics_body.php
@@ -11,7 +11,7 @@
1212 }
1313
1414 public function execute( $par ) {
15 - global $wgUser, $wgOut, $wgLang, $wgContLang;
 15+ global $wgUser, $wgOut, $wgLang, $wgContLang, $wgFlaggedRevsStats;
1616 $this->setHeaders();
1717 $this->skin = $wgUser->getSkin();
1818 $this->db = wfGetDB( DB_SLAVE );
@@ -146,12 +146,15 @@
147147 );
148148 }
149149 $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();
152152 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";
156159 $reviewChart .= '<tr><th>' . wfMsgHtml( 'validationstatistics-user' ) .
157160 '</th><th>' . wfMsgHtml( 'validationstatistics-reviews' ) . '</th></tr>';
158161 foreach ( $data as $userId => $reviews ) {
@@ -236,24 +239,31 @@
237240 return ( $val == false ? '-' : $val );
238241 }
239242
240 - protected function getTopFiveReviewers() {
 243+ // top X reviewers in the last Y hours
 244+ protected function getTopReviewers() {
 245+ global $wgFlaggedRevsStats;
 246+
241247 $key = wfMemcKey( 'flaggedrevs', 'reviewTopUsers' );
242248 $dbCache = wfGetCache( CACHE_DB );
243249 $data = $dbCache->get( $key );
244 - if ( is_array( $data ) )
 250+ if ( is_array( $data ) ) {
245251 return $data; // cache hit
 252+ }
 253+ $limit = (int)$wgFlaggedRevsStats['topReviewersCount'];
 254+ $seconds = 3600*$wgFlaggedRevsStats['topReviewersHours'];
246255
247256 $dbr = wfGetDB( DB_SLAVE );
248 - $cutoff = $dbr->timestamp( time() - 3600 );
 257+ $cutoff = $dbr->timestamp( time() - $seconds );
249258 $res = $dbr->select( 'logging',
250259 array( 'log_user', 'COUNT(*) AS reviews' ),
251260 array(
252261 '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' ),
254264 'log_timestamp >= ' . $dbr->addQuotes( $cutoff ) // last hour
255265 ),
256266 __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 )
258268 );
259269 $data = array();
260270 foreach ( $res as $row ) {

Status & tagging log