From daef9b5b34f50f2278a7b725b83c12b4914589c5 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Thu, 4 May 2006 10:38:00 +0000 Subject: [PATCH] Include page view counters in stats initialisation --- maintenance/initStats.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/maintenance/initStats.php b/maintenance/initStats.php index 844cdf7c34..06bb767101 100644 --- a/maintenance/initStats.php +++ b/maintenance/initStats.php @@ -10,7 +10,7 @@ * @licence GNU General Public Licence 2.0 or later */ -$options = array( 'help', 'update' ); +$options = array( 'help', 'update', 'noviews' ); require_once( 'commandLine.inc' ); echo( "Refresh Site Statistics\n\n" ); $dbr =& wfGetDB( DB_SLAVE ); @@ -38,7 +38,15 @@ $admin = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sys echo( "{$admin}\nCounting number of images..." ); $image = $dbr->selectField( 'image', 'COUNT(*)', '', $fname ); -echo( "{$image}\n\nUpdating site statistics..." ); +echo( "{$image}\n" ); + +if( !isset( $options['noviews'] ) ) { + echo( "Counting total page views..." ); + $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', $fname ); + echo( "{$views}\n" ); +} + +echo( "\nUpdating site statistics..." ); $dbw =& wfGetDB( DB_MASTER ); $values = array( 'ss_total_edits' => $edits, @@ -48,7 +56,7 @@ $values = array( 'ss_total_edits' => $edits, 'ss_admins' => $admin, 'ss_images' => $image ); $conds = array( 'ss_row_id' => 1 ); -$views = array( 'ss_total_views' => 0 ); +$views = array( 'ss_total_views' => isset( $views ) ? $views : 0 ); if( isset( $options['update'] ) ) { $dbw->update( 'site_stats', $values, $conds, $fname ); @@ -61,8 +69,9 @@ echo( "done.\n\n" ); function showHelp() { echo( "Re-initialise the site statistics tables.\n\n" ); - echo( "Usage: php initStats.php [--update]\n\n" ); - echo( " --update : Update the existing statistics (preserves the ss_total_views field)\n\n" ); + echo( "Usage: php initStats.php [--update|--noviews]\n\n" ); + echo( " --update : Update the existing statistics (preserves the ss_total_views field)\n" ); + echo( "--noviews : Don't update the page view counter\n\n" ); } ?> \ No newline at end of file -- 2.20.1