2005-08-29 10:22:03 +00:00
|
|
|
<?php
|
2006-05-01 15:54:20 +00:00
|
|
|
/**
|
2012-07-17 05:40:40 +00:00
|
|
|
* Re-initialise or update the site statistics table.
|
2006-05-01 15:54:20 +00:00
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-09-01 19:36:18 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2024-02-09 01:02:16 +00:00
|
|
|
* @author Brooke Vibber
|
2006-05-01 15:54:20 +00:00
|
|
|
* @author Rob Church <robchur@gmail.com>
|
|
|
|
|
*/
|
2006-05-01 15:57:22 +00:00
|
|
|
|
2023-11-21 21:08:14 +00:00
|
|
|
use MediaWiki\Deferred\SiteStatsUpdate;
|
2023-04-26 23:16:29 +00:00
|
|
|
use MediaWiki\SiteStats\SiteStatsInit;
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|
2009-08-02 19:35:17 +00:00
|
|
|
|
2012-07-17 05:40:40 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to re-initialise or update the site statistics table
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2013-02-11 09:58:42 +00:00
|
|
|
class InitSiteStats extends Maintenance {
|
2009-08-02 19:35:17 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Re-initialise the site statistics tables' );
|
2014-07-30 20:56:20 +00:00
|
|
|
$this->addOption( 'update', 'Update the existing statistics' );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->addOption( 'active', 'Also update active users count' );
|
2021-05-14 20:04:02 +00:00
|
|
|
$this->addOption( 'use-master', 'Count using the primary database' );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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..." );
|
|
|
|
|
|
2013-04-18 18:48:44 +00:00
|
|
|
$good = $counter->articles();
|
2009-08-02 19:35:17 +00:00
|
|
|
$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" );
|
|
|
|
|
|
2014-05-27 08:09:24 +00:00
|
|
|
if ( $this->hasOption( 'update' ) ) {
|
|
|
|
|
$this->output( "\nUpdating site statistics..." );
|
|
|
|
|
$counter->refresh();
|
|
|
|
|
$this->output( "done.\n" );
|
2016-03-08 19:11:06 +00:00
|
|
|
} else {
|
|
|
|
|
$this->output( "\nTo update the site statistics table, run the script "
|
|
|
|
|
. "with the --update option.\n" );
|
2014-05-27 08:09:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $this->hasOption( 'active' ) ) {
|
2014-05-27 08:09:24 +00:00
|
|
|
$this->output( "\nCounting and updating active users..." );
|
2024-01-17 18:53:40 +00:00
|
|
|
$active = SiteStatsUpdate::cacheUpdate( $this->getPrimaryDB() );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "{$active}\n" );
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 08:09:24 +00:00
|
|
|
$this->output( "\nDone.\n" );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2006-05-01 15:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = InitSiteStats::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|