Example #1
0
 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");
 }
 public function execute()
 {
     $this->output("Counting articles...");
     $counter = new SiteStatsInit(false);
     $result = $counter->articles();
     $this->output("found {$result}.\n");
     if ($this->hasOption('update')) {
         $this->output("Updating site statistics table... ");
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('site_stats', array('ss_good_articles' => $result), array('ss_row_id' => 1), __METHOD__);
         $this->output("done.\n");
     } else {
         $this->output("To update the site statistics table, run the script with the --update option.\n");
     }
 }
Example #3
0
 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('update')) {
         $this->output("\nUpdating site statistics...");
         $counter->refresh();
         $this->output("done.\n");
     } else {
         $this->output("\nTo update the site statistics table, run the script " . "with the --update option.\n");
     }
     if ($this->hasOption('active')) {
         $this->output("\nCounting and updating active users...");
         $active = SiteStatsUpdate::cacheUpdate($this->getDB(DB_MASTER));
         $this->output("{$active}\n");
     }
     $this->output("\nDone.\n");
 }
 public function execute()
 {
     $this->output("Counting articles...");
     if ($this->hasOption('use-master')) {
         $dbr = $this->getDB(DB_MASTER);
     } else {
         $dbr = $this->getDB(DB_SLAVE, 'vslow');
     }
     $counter = new SiteStatsInit($dbr);
     $result = $counter->articles();
     $this->output("found {$result}.\n");
     if ($this->hasOption('update')) {
         $this->output("Updating site statistics table... ");
         $dbw = $this->getDB(DB_MASTER);
         $dbw->update('site_stats', ['ss_good_articles' => $result], ['ss_row_id' => 1], __METHOD__);
         $this->output("done.\n");
     } else {
         $this->output("To update the site statistics table, run the script " . "with the --update option.\n");
     }
 }
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgUploadPath, $wgUser, $wgHuijiPrefix;
     $templateParser = new TemplateParser(__DIR__ . '/pages');
     $out = $this->getOutput();
     $user = $this->getUser();
     // Set the page title, robot policies, etc.
     $this->setHeaders();
     // Add Less
     $out->addModuleStyles('ext.socialprofile.admindashboard.less');
     // Add CSS
     $out->addModuleStyles('ext.socialprofile.admindashboard.css');
     // Add js and messages
     $out->addModules('ext.socialprofile.admindashboard.js');
     $output = '';
     // Prevent E_NOTICE
     $yesterday = date("Y-m-d", strtotime("-1 day"));
     $dbr = wfGetDB(DB_SLAVE);
     $counter = new SiteStatsInit($dbr);
     $totaledit = $counter->edits();
     $ueb = new UserEditBox();
     $output .= $templateParser->processTemplate('admin_index', array('yesterdayCount' => UserSiteFollow::getSiteCountOnedayDB($wgHuijiPrefix, $yesterday), 'totalCount' => UserSiteFollow::getSiteCount($wgHuijiPrefix), 'yesterdayEdit' => $ueb->getSiteEditCountOneday($wgHuijiPrefix, $yesterday), 'totalEdit' => $totaledit, 'totalView' => $ueb->getSiteViewCountTotal($wgHuijiPrefix), 'yesterdayView' => $ueb->getSiteViewCountOneday($wgHuijiPrefix, $yesterday)));
     $out->addHtml($output);
 }
Example #6
0
 /**
  * Check the site_stats table is not properly populated.
  */
 protected function checkStats()
 {
     $this->output("...site_stats is populated...");
     $row = $this->db->selectRow('site_stats', '*', array('ss_row_id' => 1), __METHOD__);
     if ($row === false) {
         $this->output("data is missing! rebuilding...\n");
     } elseif (isset($row->site_stats) && $row->ss_total_pages == -1) {
         $this->output("missing ss_total_pages, rebuilding...\n");
     } else {
         $this->output("done.\n");
         return;
     }
     SiteStatsInit::doAllAndCommit($this->db);
 }
Example #7
0
 /**
  * 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));
     }
 }
Example #8
0
 /**
  * Do all updates and commit them. More or less a replacement
  * for the original initStats, but without output.
  *
  * @param IDatabase|bool $database
  * - boolean: Whether to use the master DB
  * - IDatabase: Database connection to use
  * @param array $options Array of options, may contain the following values
  * - activeUsers boolean: Whether to update the number of active users (default: false)
  */
 public static function doAllAndCommit($database, array $options = [])
 {
     $options += ['update' => false, 'activeUsers' => false];
     // Grab the object and count everything
     $counter = new SiteStatsInit($database);
     $counter->edits();
     $counter->articles();
     $counter->pages();
     $counter->users();
     $counter->files();
     $counter->refresh();
     // Count active users if need be
     if ($options['activeUsers']) {
         SiteStatsUpdate::cacheUpdate(wfGetDB(DB_MASTER));
     }
 }
Example #9
0
 /**
  * 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));
     }
 }