public function execute() { $this->output("Refresh Site Statistics\n\n"); $counter = new SiteStatsInit($this->hasOption('use-master')); $this->output("Counting total edits..."); $edits = $counter->edits(); $this->output("{$edits}\nCounting number of articles..."); $good = $counter->articles(); $this->output("{$good}\nCounting total pages..."); $pages = $counter->pages(); $this->output("{$pages}\nCounting number of users..."); $users = $counter->users(); $this->output("{$users}\nCounting number of images..."); $image = $counter->files(); $this->output("{$image}\n"); if (!$this->hasOption('noviews')) { $this->output("Counting total page views..."); $views = $counter->views(); $this->output("{$views}\n"); } if ($this->hasOption('active')) { $this->output("Counting active users..."); $active = SiteStatsUpdate::cacheUpdate(); $this->output("{$active}\n"); } $this->output("\nUpdating site statistics..."); if ($this->hasOption('update')) { $counter->update(); } else { $counter->refresh(); } $this->output("done.\n"); }
/** * Do all updates and commit them. More or less a replacement * for the original initStats, but without output. * * @param $database DatabaseBase|bool * - Boolean: whether to use the master DB * - DatabaseBase: database connection to use * @param array $options of options, may contain the following values * - update Boolean: whether to update the current stats (true) or write fresh (false) (default: false) * - views Boolean: when true, do not update the number of page views (default: true) * - activeUsers Boolean: whether to update the number of active users (default: false) */ public static function doAllAndCommit($database, array $options = array()) { $options += array('update' => false, 'views' => true, 'activeUsers' => false); // Grab the object and count everything $counter = new SiteStatsInit($database); $counter->edits(); $counter->articles(); $counter->pages(); $counter->users(); $counter->files(); // Only do views if we don't want to not count them if ($options['views']) { $counter->views(); } // Update/refresh if ($options['update']) { $counter->update(); } else { $counter->refresh(); } // Count active users if need be if ($options['activeUsers']) { SiteStatsUpdate::cacheUpdate(wfGetDB(DB_MASTER)); } }
/** * Do all updates and commit them. More or less a replacement * for the original initStats, but without the calls to wfOut() * @param $update Boolean: whether to update the current stats or write fresh * @param $noViews Boolean: when true, do not update the number of page views * @param $activeUsers Boolean: whether to update the number of active users */ public static function doAllAndCommit($update, $noViews = false, $activeUsers = false) { // Grab the object and count everything $counter = new SiteStatsInit(false); $counter->edits(); $counter->articles(); $counter->pages(); $counter->users(); $counter->files(); // Only do views if we don't want to not count them if (!$noViews) { $counter->views(); } // Update/refresh if ($update) { $counter->update(); } else { $counter->refresh(); } // Count active users if need be if ($activeUsers) { SiteStatsUpdate::cacheUpdate(wfGetDB(DB_MASTER)); } }