r52513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52512‎ | r52513 | r52514 >
Date:15:33, 28 June 2009
Author:demon
Status:deferred
Tags:
Comment:
(bug 18930) initStats does not refresh active_users count
Modified paths:
  • /branches/maintenance-work/includes/SiteStats.php (modified) (history)
  • /branches/maintenance-work/maintenance/initStats.php (modified) (history)

Diff [purge]

Index: branches/maintenance-work/maintenance/initStats.php
@@ -18,11 +18,12 @@
1919 $this->mDescription = "Re-initialise the site statistics tables";
2020 $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
2121 $this->addOption( 'noviews', "Don't update the page view counter" );
 22+ $this->addOption( 'active', 'Also update active users count' );
2223 }
2324
2425 public function execute() {
2526 $this->output( "Refresh Site Statistics\n\n" );
26 - SiteStats::init( $this->hasOption('update'), $this->hasOption('noviews') );
 27+ SiteStats::init( $this->hasOption('update'), $this->hasOption('noviews'), $this->hasOption('active') );
2728 }
2829 }
2930
Index: branches/maintenance-work/includes/SiteStats.php
@@ -180,35 +180,41 @@
181181 * @param $update bool Whether to update the current stats write fresh
182182 * @param $noViews bool When true, do not update the number of page views
183183 */
184 - public static function init( $update, $noViews = false ) {
 184+ public static function init( $update, $noViews = false, $activeUsers = false ) {
185185 $dbr = wfGetDB( DB_SLAVE );
186 -
 186+
187187 wfOut( "Counting total edits..." );
188188 $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', __METHOD__ );
189189 $edits += $dbr->selectField( 'archive', 'COUNT(*)', '', __METHOD__ );
190190 wfOut( "{$edits}\nCounting number of articles..." );
191 -
 191+
192192 global $wgContentNamespaces;
193193 $good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $wgContentNamespaces, 'page_is_redirect' => 0, 'page_len > 0' ), __METHOD__ );
194194 wfOut( "{$good}\nCounting total pages..." );
195 -
 195+
196196 $pages = $dbr->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
197197 wfOut( "{$pages}\nCounting number of users..." );
198198
199199 $users = $dbr->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
200200 wfOut( "{$users}\nCounting number of admins..." );
201 -
 201+
202202 $admin = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
203203 wfOut( "{$admin}\nCounting number of images..." );
204204
205205 $image = $dbr->selectField( 'image', 'COUNT(*)', '', __METHOD__ );
206206 wfOut( "{$image}\n" );
207 -
 207+
208208 if( !$noViews ) {
209209 wfOut( "Counting total page views..." );
210210 $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ );
211211 wfOut( "{$views}\n" );
212212 }
 213+
 214+ if( $activeUsers ) {
 215+ wfOut( "Counting active users..." );
 216+ $active = SiteStatsUpdate::cacheUpdate();
 217+ wfOut( "{$active}\n" );
 218+ }
213219
214220 wfOut( "\nUpdating site statistics..." );
215221
@@ -296,5 +302,6 @@
297303 array( 'ss_active_users' => intval($activeUsers) ),
298304 array( 'ss_row_id' => 1 ), __METHOD__
299305 );
 306+ return $activeUsers;
300307 }
301308 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r54225Merge maintenance-work branch (now with less errors!):...demon19:35, 2 August 2009

Status & tagging log