Revision: 52513 Author: demon Date: 2009-06-28 15:33:44 +0000 (Sun, 28 Jun 2009)
Log Message: ----------- (bug 18930) initStats does not refresh active_users count Modified Paths: -------------- branches/maintenance-work/includes/SiteStats.php branches/maintenance-work/maintenance/initStats.php Modified: branches/maintenance-work/includes/SiteStats.php =================================================================== --- branches/maintenance-work/includes/SiteStats.php 2009-06-28 15:20:51 UTC (rev 52512) +++ branches/maintenance-work/includes/SiteStats.php 2009-06-28 15:33:44 UTC (rev 52513) @@ -180,35 +180,41 @@ * @param $update bool Whether to update the current stats write fresh * @param $noViews bool When true, do not update the number of page views */ - public static function init( $update, $noViews = false ) { + public static function init( $update, $noViews = false, $activeUsers = false ) { $dbr = wfGetDB( DB_SLAVE ); - + wfOut( "Counting total edits..." ); $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', __METHOD__ ); $edits += $dbr->selectField( 'archive', 'COUNT(*)', '', __METHOD__ ); wfOut( "{$edits}\nCounting number of articles..." ); - + global $wgContentNamespaces; $good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $wgContentNamespaces, 'page_is_redirect' => 0, 'page_len > 0' ), __METHOD__ ); wfOut( "{$good}\nCounting total pages..." ); - + $pages = $dbr->selectField( 'page', 'COUNT(*)', '', __METHOD__ ); wfOut( "{$pages}\nCounting number of users..." ); $users = $dbr->selectField( 'user', 'COUNT(*)', '', __METHOD__ ); wfOut( "{$users}\nCounting number of admins..." ); - + $admin = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ ); wfOut( "{$admin}\nCounting number of images..." ); $image = $dbr->selectField( 'image', 'COUNT(*)', '', __METHOD__ ); wfOut( "{$image}\n" ); - + if( !$noViews ) { wfOut( "Counting total page views..." ); $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ ); wfOut( "{$views}\n" ); } + + if( $activeUsers ) { + wfOut( "Counting active users..." ); + $active = SiteStatsUpdate::cacheUpdate(); + wfOut( "{$active}\n" ); + } wfOut( "\nUpdating site statistics..." ); @@ -296,5 +302,6 @@ array( 'ss_active_users' => intval($activeUsers) ), array( 'ss_row_id' => 1 ), __METHOD__ ); + return $activeUsers; } } Modified: branches/maintenance-work/maintenance/initStats.php =================================================================== --- branches/maintenance-work/maintenance/initStats.php 2009-06-28 15:20:51 UTC (rev 52512) +++ branches/maintenance-work/maintenance/initStats.php 2009-06-28 15:33:44 UTC (rev 52513) @@ -18,11 +18,12 @@ $this->mDescription = "Re-initialise the site statistics tables"; $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' ); $this->addOption( 'noviews', "Don't update the page view counter" ); + $this->addOption( 'active', 'Also update active users count' ); } public function execute() { $this->output( "Refresh Site Statistics\n\n" ); - SiteStats::init( $this->hasOption('update'), $this->hasOption('noviews') ); + SiteStats::init( $this->hasOption('update'), $this->hasOption('noviews'), $this->hasOption('active') ); } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs