Made active users concept have some meaning by decoupling it from recent changes...
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 18 Jul 2010 07:15:27 +0000 (07:15 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 18 Jul 2010 07:15:27 +0000 (07:15 +0000)
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.

includes/DefaultSettings.php
includes/SiteStats.php
includes/specials/SpecialActiveusers.php
includes/specials/SpecialStatistics.php

index 505cc85..ddab411 100644 (file)
@@ -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 }
 
 /************************************************************************//**
index b07bdbb..11cef56 100644 (file)
@@ -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__
                );
index eb8478d..80db368 100644 (file)
@@ -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 ) {
index 3bb45d0..d3c1a76 100644 (file)
@@ -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;