r47069 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47068‎ | r47069 | r47070 >
Date:00:50, 10 February 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Made query happen only on submit
Modified paths:
  • /trunk/tools/WikipediaStatistics/index.php (modified) (history)

Diff [purge]

Index: trunk/tools/WikipediaStatistics/index.php
@@ -81,41 +81,43 @@
8282 <hr noshade="noshade" size="1" />
8383 <pre><?php
8484
85 - $dbr = new Database();
86 - $dateRange = array(
87 - sprintf(
88 - 'rev_timestamp > %s',
89 - $dbr->addQuotes( date( 'Ymd', strtotime( $parameters['from'] ) )
90 - )
91 - ),
92 - sprintf(
93 - 'rev_timestamp < %s',
94 - $dbr->addQuotes( date( 'Ymd', strtotime( $parameters['to'] ) )
95 - )
96 - ),
97 - );
98 - switch ( $parameters['type'] ) {
99 - case 'edits':
100 - $result = $dbr->select(
101 - 'revision',
102 - 'COUNT( rev_id )',
103 - $dateRange,
104 - array( 'LIMIT' => 1 )
105 - );
106 - break;
107 - case 'editors':
108 - $result = $dbr->select(
109 - 'revision',
110 - 'DISTINCT COUNT( rev_user )',
111 - $dateRange,
112 - array( 'LIMIT' => 1 )
113 - );
114 - break;
115 - }
116 - if ( isset( $result ) ) {
117 - while( $row = $result->fetchRow() ) {
118 - echo $row[0];
 85+ if ( isset( $_POST['submit'] ) ) {
 86+ $dbr = new Database();
 87+ $dateRange = array(
 88+ sprintf(
 89+ 'rev_timestamp > %s',
 90+ $dbr->addQuotes( date( 'Ymd', strtotime( $parameters['from'] ) )
 91+ )
 92+ ),
 93+ sprintf(
 94+ 'rev_timestamp < %s',
 95+ $dbr->addQuotes( date( 'Ymd', strtotime( $parameters['to'] ) )
 96+ )
 97+ ),
 98+ );
 99+ switch ( $parameters['type'] ) {
 100+ case 'edits':
 101+ $result = $dbr->select(
 102+ 'revision',
 103+ 'COUNT( rev_id )',
 104+ $dateRange,
 105+ array( 'LIMIT' => 1 )
 106+ );
 107+ break;
 108+ case 'editors':
 109+ $result = $dbr->select(
 110+ 'revision',
 111+ 'DISTINCT COUNT( rev_user )',
 112+ $dateRange,
 113+ array( 'LIMIT' => 1 )
 114+ );
 115+ break;
119116 }
 117+ if ( isset( $result ) ) {
 118+ while( $row = $result->fetchRow() ) {
 119+ echo $row[0];
 120+ }
 121+ }
120122 }
121123
122124 ?></pre>

Status & tagging log