From: Niklas Laxström Date: Sun, 18 Jul 2010 07:15:27 +0000 (+0000) Subject: Made active users concept have some meaning by decoupling it from recent changes... X-Git-Tag: 1.31.0-rc.0~36111 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=ab662057d5a41cf194cf67f0cb6b21a402013e08;p=lhc%2Fweb%2Fwiklou.git Made active users concept have some meaning by decoupling it from recent changes length. Introduced wgActiveUserDays, which defaults to 30 days as used on wmf. This way the number can be more easily compared between wikis. We no longer lie to users if the actual rc length is longer than the limit. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 505cc85fb1..ddab4111c6 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2715,6 +2715,14 @@ $wgUseCommaCount = false; */ $wgHitcounterUpdateFreq = 1; +/** + * How many days user must be idle before he is considered inactive. Will affect + * the number shown on Special:Statistics and Special:ActiveUsers special page. + * You might want to leave this as the default value, to provide comparable + * numbers between different wikis. + */ +$wgActiveUserDays = 30; + /** @} */ # End of statistics } /************************************************************************//** diff --git a/includes/SiteStats.php b/includes/SiteStats.php index b07bdbbe07..11cef56f1b 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -234,6 +234,7 @@ class SiteStatsUpdate { } public static function cacheUpdate( $dbw ) { + global $wgActiveUserDays; $dbr = wfGetDB( DB_SLAVE, array( 'SpecialStatistics', 'vslow' ) ); # Get non-bot users than did some recent action other than making accounts. # If account creation is included, the number gets inflated ~20+ fold on enwiki. @@ -243,7 +244,8 @@ class SiteStatsUpdate { array( 'rc_user != 0', 'rc_bot' => 0, - "rc_log_type != 'newusers' OR rc_log_type IS NULL" + "rc_log_type != 'newusers' OR rc_log_type IS NULL", + "rc_timestamp >= '{$dbw->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 )}'", ), __METHOD__ ); diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index eb8478d20a..80db3680da 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -29,9 +29,8 @@ class ActiveUsersPager extends UsersPager { function __construct( $group = null ) { - global $wgRequest, $wgRCMaxAge; - $this->RCMaxAge = ceil( $wgRCMaxAge / ( 3600 * 24 ) ); // Constant - + global $wgRequest, $wgActiveUserDays; + $this->RCMaxAge = $wgActiveUserDays; $un = $wgRequest->getText( 'username' ); $this->requestedUser = ''; if ( $un != '' ) { @@ -72,6 +71,7 @@ class ActiveUsersPager extends UsersPager { $conds = array( 'rc_user > 0' ); // Users - no anons $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names $conds[] = "rc_log_type IS NULL OR rc_log_type != 'newusers'"; + $conds[] = "rc_timestamp >= '{$dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 )}'"; if( $this->requestedUser != '' ) { $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser ); @@ -167,7 +167,7 @@ class SpecialActiveUsers extends SpecialPage { * @param $par Mixed: parameter passed to the page or null */ public function execute( $par ) { - global $wgOut, $wgLang, $wgRCMaxAge; + global $wgOut, $wgLang, $wgActiveUserDays; $this->setHeaders(); $this->outputHeader(); @@ -177,9 +177,9 @@ class SpecialActiveUsers extends SpecialPage { # getBody() first to check, if empty $usersbody = $up->getBody(); - $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ), - wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( ceil( $wgRCMaxAge / 86400 ) ) ) - ); + $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ), + wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( $wgActiveUserDays ) ) + ); $s .= $up->getPageHeader(); if( $usersbody ) { diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index 3bb45d033d..d3c1a767e6 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -174,7 +174,7 @@ class SpecialStatistics extends SpecialPage { } private function getUserStats() { - global $wgLang, $wgUser, $wgRCMaxAge; + global $wgLang, $wgUser, $wgActiveUserDays; $sk = $wgUser->getSkin(); return Xml::openElement( 'tr' ) . Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-users', array( 'parseinline' ) ) ) . @@ -193,7 +193,7 @@ class SpecialStatistics extends SpecialPage { $wgLang->formatNum( $this->activeUsers ), array( 'class' => 'mw-statistics-users-active' ), 'statistics-users-active-desc', - $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) ); + $wgLang->formatNum( $wgActiveUserDays ) ); } private function getGroupStats() { global $wgGroupPermissions, $wgImplicitGroups, $wgLang, $wgUser;