Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/YearlyTotal_body.php |
— | — | @@ -1,81 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Special Page for Contribution statistics extension |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Extensions |
8 | | - */ |
9 | | - |
10 | | -class SpecialYearlyTotal extends IncludableSpecialPage { |
11 | | - |
12 | | - protected $sharedMaxAge = 600; // Cache for 10 minutes on the server side |
13 | | - protected $maxAge = 600; // Cache for 10 minutes on the client side |
14 | | - |
15 | | - /* Functions */ |
16 | | - |
17 | | - public function __construct() { |
18 | | - parent::__construct( 'YearlyTotal' ); |
19 | | - } |
20 | | - |
21 | | - public function execute( $sub ) { |
22 | | - global $wgRequest, $wgOut, $egFundraiserStatisticsFundraisers; |
23 | | - |
24 | | - $js = $wgRequest->getBool( 'js', false ); |
25 | | - |
26 | | - $adjustment = $wgRequest->getVal( 'adjustment' ); |
27 | | - // Make sure it's a number |
28 | | - if ( is_nan( $adjustment ) ) { |
29 | | - $adjustment = 0; |
30 | | - } |
31 | | - |
32 | | - /* Setup */ |
33 | | - $wgOut->disable(); |
34 | | - $this->sendHeaders(); |
35 | | - |
36 | | - $total = $this->query( $adjustment ); |
37 | | - |
38 | | - $content = "wgFundraisingYearlyTotal = $total;"; |
39 | | - |
40 | | - if ( $js ) { |
41 | | - echo $content; |
42 | | - } else { |
43 | | - echo $total; |
44 | | - } |
45 | | - } |
46 | | - |
47 | | - /* Private Functions */ |
48 | | - |
49 | | - private function query( $adjustment ) { |
50 | | - global $wgMemc, $egFundraiserStatisticsCacheTimeout, $egFundraiserStatisticsFundraisers; |
51 | | - |
52 | | - $currenctFundraiserIndex = count( $egFundraiserStatisticsFundraisers ) - 1; |
53 | | - $year = $egFundraiserStatisticsFundraisers[$currenctFundraiserIndex]['id']; |
54 | | - |
55 | | - $key = wfMemcKey( 'fundraiserstatistics', $year, $adjustment ); |
56 | | - $cache = $wgMemc->get( $key ); |
57 | | - if ( $cache != false && $cache != -1 ) { |
58 | | - return $cache; |
59 | | - } |
60 | | - |
61 | | - // Get the timestamp for the start of the current fundraiser |
62 | | - // Note: This depends on the fundraisers being listed in chronological order |
63 | | - $start = strtotime( $egFundraiserStatisticsFundraisers[$currenctFundraiserIndex]['start'] ); |
64 | | - $start = intval( wfTimestampOrNull( TS_UNIX, $start ) ); |
65 | | - |
66 | | - $total = efContributionReportingTotal( $start, $adjustment ); |
67 | | - if ( !$total ) $total = 0; |
68 | | - |
69 | | - $wgMemc->set( $key, $total, $egFundraiserStatisticsCacheTimeout ); |
70 | | - return $total; |
71 | | - } |
72 | | - |
73 | | - private function sendHeaders() { |
74 | | - global $wgJsMimeType; |
75 | | - header( "Content-type: $wgJsMimeType; charset=utf-8" ); |
76 | | - header( "Cache-Control: public, s-maxage=$this->sharedMaxAge, max-age=$this->maxAge" ); |
77 | | - } |
78 | | - |
79 | | - public function isListed(){ |
80 | | - return false; |
81 | | - } |
82 | | -} |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.php |
— | — | @@ -11,12 +11,18 @@ |
12 | 12 | |
13 | 13 | $wgContributionReportingBaseURL = "http://meta.wikimedia.org/w/index.php?title=Special:NoticeTemplate/view&template="; |
14 | 14 | |
15 | | -// Override these with appropriate DB settings for the CiviCRM database... |
| 15 | +// Override these with appropriate DB settings for the CiviCRM master database... |
16 | 16 | $wgContributionReportingDBserver = $wgDBserver; |
17 | 17 | $wgContributionReportingDBuser = $wgDBuser; |
18 | 18 | $wgContributionReportingDBpassword = $wgDBpassword; |
19 | 19 | $wgContributionReportingDBname = $wgDBname; |
20 | 20 | |
| 21 | +// Override these with appropriate DB settings for the CiviCRM slave database... |
| 22 | +$wgContributionReportingReadDBserver = $wgDBserver; |
| 23 | +$wgContributionReportingReadDBuser = $wgDBuser; |
| 24 | +$wgContributionReportingReadDBpassword = $wgDBpassword; |
| 25 | +$wgContributionReportingReadDBname = $wgDBname; |
| 26 | + |
21 | 27 | // And now the tracking database |
22 | 28 | $wgContributionTrackingDBserver = $wgDBserver; |
23 | 29 | $wgContributionTrackingDBuser = $wgDBuser; |
— | — | @@ -26,7 +32,7 @@ |
27 | 33 | $wgExtensionCredits['specialpage'][] = array( |
28 | 34 | 'path' => __FILE__, |
29 | 35 | 'name' => 'Contribution Reporting', |
30 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:ContributionReporting', |
| 36 | + 'url' => 'https://www.mediawiki.org/wiki/Extension:ContributionReporting', |
31 | 37 | 'author' => array( 'David Strauss', 'Brion Vibber', 'Siebrand Mazeland', 'Trevor Parscal', 'Tomasz Finc' ), |
32 | 38 | 'descriptionmsg' => 'contributionreporting-desc', |
33 | 39 | ); |
— | — | @@ -41,9 +47,8 @@ |
42 | 48 | $wgAutoloadClasses['SpecialContributionStatistics'] = $dir . 'ContributionStatistics_body.php'; |
43 | 49 | $wgAutoloadClasses['SpecialFundraiserStatistics'] = $dir . 'FundraiserStatistics_body.php'; |
44 | 50 | $wgAutoloadClasses['SpecialContributionTrackingStatistics'] = $dir . 'ContributionTrackingStatistics_body.php'; |
| 51 | +$wgAutoloadClasses['SpecialDailyTotal'] = $dir . 'DailyTotal_body.php'; |
45 | 52 | /* |
46 | | -$wgAutoloadClasses['SpecialDailyTotal'] = $dir . 'DailyTotal_body.php'; |
47 | | -$wgAutoloadClasses['SpecialYearlyTotal'] = $dir . 'YearlyTotal_body.php'; |
48 | 53 | $wgAutoloadClasses['DisabledNotice'] = $dir . 'DisabledNotice_body.php'; |
49 | 54 | */ |
50 | 55 | |
— | — | @@ -52,10 +57,7 @@ |
53 | 58 | $wgSpecialPages['ContributionStatistics'] = 'SpecialContributionStatistics'; |
54 | 59 | $wgSpecialPages['FundraiserStatistics'] = 'SpecialFundraiserStatistics'; |
55 | 60 | $wgSpecialPages['ContributionTrackingStatistics'] = 'SpecialContributionTrackingStatistics'; |
56 | | -/* |
57 | 61 | $wgSpecialPages['DailyTotal'] = 'SpecialDailyTotal'; |
58 | | -$wgSpecialPages['YearlyTotal'] = 'SpecialYearlyTotal'; |
59 | | -*/ |
60 | 62 | |
61 | 63 | $wgSpecialPageGroups['ContributionHistory'] = 'contribution'; |
62 | 64 | $wgSpecialPageGroups['ContributionTotal'] = 'contribution'; |
— | — | @@ -154,6 +156,8 @@ |
155 | 157 | } |
156 | 158 | |
157 | 159 | /** |
| 160 | + * Define the contributiontotal magic word |
| 161 | + * Example: {{#contributiontotal:fundraiser=2011|fudgefactor=0}} |
158 | 162 | * @param $magicWords array |
159 | 163 | * @param $langCode string |
160 | 164 | * @return bool |
— | — | @@ -165,6 +169,7 @@ |
166 | 170 | |
167 | 171 | /** |
168 | 172 | * Automatically use a local or special database connection for reporting |
| 173 | + * This connection will typically be to the CiviCRM master database |
169 | 174 | * @return DatabaseMysql |
170 | 175 | */ |
171 | 176 | function efContributionReportingConnection() { |
— | — | @@ -186,6 +191,29 @@ |
187 | 192 | } |
188 | 193 | |
189 | 194 | /** |
| 195 | + * Automatically use a local or special database connection for reporting |
| 196 | + * This connection will typically be to a CiviCRM slave database |
| 197 | + * @return DatabaseMysql |
| 198 | + */ |
| 199 | +function efContributionReportingReadConnection() { |
| 200 | + global $wgContributionReportingReadDBserver, $wgContributionReportingReadDBname; |
| 201 | + global $wgContributionReportingReadDBuser, $wgContributionReportingReadDBpassword; |
| 202 | + |
| 203 | + static $db; |
| 204 | + |
| 205 | + if ( !$db ) { |
| 206 | + $db = new DatabaseMysql( |
| 207 | + $wgContributionReportingReadDBserver, |
| 208 | + $wgContributionReportingReadDBuser, |
| 209 | + $wgContributionReportingReadDBpassword, |
| 210 | + $wgContributionReportingReadDBname ); |
| 211 | + $db->query( "SET names utf8" ); |
| 212 | + } |
| 213 | + |
| 214 | + return $db; |
| 215 | +} |
| 216 | + |
| 217 | +/** |
190 | 218 | * Automatically use a local or special database connection for tracking |
191 | 219 | * @return DatabaseMysql |
192 | 220 | */ |
— | — | @@ -208,39 +236,67 @@ |
209 | 237 | } |
210 | 238 | |
211 | 239 | /** |
212 | | - * Get the total amount of money raised since the start of the fundraiser |
213 | | - * @param $start |
214 | | - * @param $fudgeFactor |
215 | | - * @return string |
| 240 | + * Get the total amount of money raised for a specific fundraiser |
| 241 | + * @param string $fundraiser The ID of the fundraiser to return the current total for |
| 242 | + * @param int $fudgeFactor How much to adjust the total by |
| 243 | + * @return integer |
216 | 244 | */ |
217 | | -function efContributionReportingTotal( $start, $fudgeFactor ) { |
218 | | - $db = efContributionReportingConnection(); |
| 245 | +function efContributionReportingTotal( $fundraiser, $fudgeFactor = 0 ) { |
| 246 | + global $wgMemc, $egFundraiserStatisticsFundraisers, $egFundraiserStatisticsCacheTimeout; |
219 | 247 | |
220 | | - $sql = 'SELECT ROUND( SUM(converted_amount) ) AS ttl FROM public_reporting'; |
221 | | - |
222 | | - if ( $start ) { |
223 | | - $sql .= ' WHERE received >= ' . $db->addQuotes( wfTimestamp( TS_UNIX, $start ) ); |
| 248 | + // If a total is cached, use that |
| 249 | + $key = wfMemcKey( 'contributionreportingtotal', $fundraiser, $fudgeFactor ); |
| 250 | + $cache = $wgMemc->get( $key ); |
| 251 | + if ( $cache != false && $cache != -1 ) { |
| 252 | + return $cache; |
224 | 253 | } |
| 254 | + |
| 255 | + $dbr = wfGetDB( DB_SLAVE ); |
| 256 | + |
| 257 | + // Find the index number for the requested fundraiser |
| 258 | + $myFundraiserIndex = false; |
| 259 | + foreach ( $egFundraiserStatisticsFundraisers as $fundraiserIndex => $fundraiserArray ) { |
| 260 | + if ( $fundraiserArray['id'] == $fundraiser ) { |
| 261 | + $myFundraiserIndex = $fundraiserIndex; |
| 262 | + break; |
| 263 | + } |
| 264 | + } |
| 265 | + if ( !$myFundraiserIndex ) { |
| 266 | + // If none was found, use the most recent fundraiser |
| 267 | + $myFundraiserIndex = count( $egFundraiserStatisticsFundraisers ) - 1; |
| 268 | + } |
| 269 | + |
| 270 | + $myFundraiser = $egFundraiserStatisticsFundraisers[$myFundraiserIndex]; |
225 | 271 | |
226 | | - $res = $db->query( $sql ); |
227 | | - |
228 | | - $row = $res->fetchRow(); |
229 | | - |
230 | | - # Output |
231 | | - $output = $row['ttl'] ? $row['ttl'] : '0'; |
| 272 | + // First, try to get the total from the summary table |
| 273 | + $result = $dbr->select( |
| 274 | + 'public_reporting_fundraisers', |
| 275 | + 'round( prf_total ) AS total', |
| 276 | + array( 'prf_id' => $myFundraiser['id'] ), |
| 277 | + __METHOD__ |
| 278 | + ); |
| 279 | + $row = $dbr->fetchRow( $result ); |
232 | 280 | |
233 | | - // Make sure fudge factor is a number |
| 281 | + if ( $row['total'] > 0 ) { |
| 282 | + $total = $row['total']; |
| 283 | + } else { |
| 284 | + $total = 0; |
| 285 | + } |
| 286 | + |
| 287 | + // Make sure the fudge factor is a number |
234 | 288 | if ( is_nan( $fudgeFactor ) ) { |
235 | 289 | $fudgeFactor = 0; |
236 | 290 | } |
237 | 291 | |
238 | | - $output += $fudgeFactor; |
| 292 | + // Add the fudge factor to the total |
| 293 | + $total += $fudgeFactor; |
239 | 294 | |
240 | | - return $output; |
| 295 | + $wgMemc->set( $key, $total, $egFundraiserStatisticsCacheTimeout ); |
| 296 | + return $total; |
241 | 297 | } |
242 | 298 | |
243 | 299 | /** |
244 | | - * @return string |
| 300 | + * @return integer |
245 | 301 | */ |
246 | 302 | function efContributionReportingTotal_Render() { |
247 | 303 | $args = func_get_args(); |
— | — | @@ -250,18 +306,18 @@ |
251 | 307 | $start = false; |
252 | 308 | |
253 | 309 | foreach( $args as $arg ) { |
254 | | - if ( strpos($arg,'=') === false ) { |
| 310 | + if ( strpos( $arg,'=' ) === false ) { |
255 | 311 | continue; |
256 | 312 | } |
257 | 313 | |
258 | | - list($key,$value) = explode( '=', trim($arg), 2 ); |
| 314 | + list( $key, $value ) = explode( '=', trim( $arg ), 2 ); |
259 | 315 | |
260 | | - if ($key == 'fudgefactor') { |
| 316 | + if ( $key == 'fudgefactor' ) { |
261 | 317 | $fudgeFactor = $value; |
262 | | - } elseif ($key == 'start') { |
263 | | - $start = $value; |
| 318 | + } elseif ( $key == 'fundraiser' ) { |
| 319 | + $fundraiser = $value; |
264 | 320 | } |
265 | 321 | } |
266 | 322 | |
267 | | - return efContributionReportingTotal( $start, $fudgeFactor ); |
| 323 | + return efContributionReportingTotal( $fundraiser, $fudgeFactor ); |
268 | 324 | } |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
269 | 325 | Merged /trunk/extensions/ContributionReporting/ContributionReporting.php:r105657,105659,105757,105916,105965,106136,106234,106239,106246,106287,106362 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionTrackingStatistics_body.php |
— | — | @@ -19,6 +19,10 @@ |
20 | 20 | |
21 | 21 | public function execute( $sub ) { |
22 | 22 | global $wgOut, $wgRequest; |
| 23 | + |
| 24 | + # Emergency short cut until this is back in working order |
| 25 | + $wgOut->redirect( SpecialPage::getTitleFor( 'FundraiserStatistics' )->getFullURL() ); |
| 26 | + return; |
23 | 27 | |
24 | 28 | $start = $wgRequest->getIntOrNull( 'start' ); |
25 | 29 | $end = $wgRequest->getIntOrNull( 'end' ); |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionTrackingStatistics_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
26 | 30 | Merged /trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php:r105965,106362 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/FundraiserStatistics_body.php |
— | — | @@ -307,7 +307,7 @@ |
308 | 308 | * Retrieve the donation data from the database |
309 | 309 | * |
310 | 310 | * @param boolean $mostRecent Is this query for the most recent fundraiser? |
311 | | - * @param string $start The start date for a fundraiser |
| 311 | + * @param string $start The start date for a fundraiser, e.g. 'Oct 22 2007' |
312 | 312 | * @param string $end The end date for a fundraiser |
313 | 313 | * @return an array of results or null |
314 | 314 | */ |
— | — | @@ -323,31 +323,32 @@ |
324 | 324 | return $cache; |
325 | 325 | } |
326 | 326 | |
327 | | - // Use database |
328 | | - $dbr = efContributionReportingConnection(); |
| 327 | + // Use MediaWiki slave database |
| 328 | + $dbr = wfGetDB( DB_SLAVE ); |
| 329 | + // Set timezone to UTC (contribution data will always be in UTC) |
| 330 | + date_default_timezone_set( 'UTC' ); |
| 331 | + |
329 | 332 | $conditions = array( |
330 | | - 'received >= ' . $dbr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $start ) ) ), |
331 | | - 'received <= ' . $dbr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $end ) + 24 * 60 * 60 ) ), |
332 | | - 'converted_amount >= ' . $egFundraiserStatisticsMinimum, |
333 | | - 'converted_amount <= ' . $egFundraiserStatisticsMaximum |
| 333 | + 'prd_date >= ' . $dbr->addQuotes( wfTimestamp( TS_DB, strtotime( $start ) ) ), |
| 334 | + 'prd_date <= ' . $dbr->addQuotes( wfTimestamp( TS_DB, strtotime( $end ) ) ), |
334 | 335 | ); |
335 | 336 | |
336 | 337 | // Get the data for a fundraiser |
337 | | - $select = $dbr->select( 'public_reporting', |
| 338 | + $select = $dbr->select( 'public_reporting_days', |
338 | 339 | array( |
339 | | - "DATE_FORMAT(FROM_UNIXTIME(received),'%Y-%m-%d')", |
340 | | - 'sum(converted_amount)', |
341 | | - 'count(*)', |
342 | | - 'avg(converted_amount)', |
343 | | - 'max(converted_amount)', |
| 340 | + 'prd_date', |
| 341 | + 'prd_total', |
| 342 | + 'prd_number', |
| 343 | + 'prd_average', |
| 344 | + 'prd_maximum', |
344 | 345 | ), |
345 | 346 | $conditions, |
346 | 347 | __METHOD__, |
347 | 348 | array( |
348 | | - 'ORDER BY' => 'received', |
349 | | - 'GROUP BY' => "DATE_FORMAT(FROM_UNIXTIME(received),'%Y-%m-%d')" |
| 349 | + 'ORDER BY' => 'prd_date', |
350 | 350 | ) |
351 | 351 | ); |
| 352 | + |
352 | 353 | $result = array(); |
353 | 354 | $ytd = 0; |
354 | 355 | while ( $row = $dbr->fetchRow( $select ) ) { |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/FundraiserStatistics_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
355 | 356 | Merged /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php:r105916,105965,106246,106287,106362 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionHistory_body.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | function execute( $language ) { |
9 | 9 | global $wgRequest, $wgOut, $wgLang; |
10 | 10 | |
11 | | - # Emergecny short cut until post donation comments are enabled |
| 11 | + # Emergency short cut until post donation comments are enabled |
12 | 12 | $wgOut->redirect( SpecialPage::getTitleFor( 'FundraiserStatistics' )->getFullURL() ); |
13 | 13 | return; |
14 | 14 | |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | // Paging controls |
32 | 32 | $newer = $db->selectField( 'public_reporting', 'received', |
33 | 33 | array_merge( |
34 | | - array( 'received > ' . strtotime( 'July 1st 2008' ) ), |
| 34 | + array( 'received > ' . strtotime( 'July 1st 2011' ) ), |
35 | 35 | ( $offset !== null ? array( 'received > ' . $offset ) : array() ) |
36 | 36 | ), |
37 | 37 | __METHOD__, |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | ); |
44 | 44 | $older = $db->selectField( 'public_reporting', 'received', |
45 | 45 | array_merge( |
46 | | - array( 'received > ' . strtotime( 'July 1st 2008' ) ), |
| 46 | + array( 'received > ' . strtotime( 'July 1st 2011' ) ), |
47 | 47 | ( $offset !== null ? array( 'received <= ' . $offset ) : array() ) |
48 | 48 | ), |
49 | 49 | __METHOD__, |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | |
87 | 87 | if ( $offset == null ) { |
88 | 88 | $offset = $db->selectField( 'public_reporting', 'received', |
89 | | - array( 'received > ' . strtotime( 'July 1st 2008' ) ), |
| 89 | + array( 'received > ' . strtotime( 'July 1st 2011' ) ), |
90 | 90 | __METHOD__, |
91 | 91 | array( |
92 | 92 | 'ORDER BY' => 'received DESC', |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | |
100 | 100 | $res = $db->select( 'public_reporting', '*', |
101 | 101 | array_merge( |
102 | | - array( 'received > ' . strtotime( 'July 1st 2008' ) ), |
| 102 | + array( 'received > ' . strtotime( 'July 1st 2011' ) ), |
103 | 103 | ( $offset !== null ? array( 'received <= ' . $offset ) : array() ) |
104 | 104 | ), |
105 | 105 | __METHOD__, |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionHistory_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
106 | 106 | Merged /trunk/extensions/ContributionReporting/ContributionHistory_body.php:r105965,106362 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/PopulateFundraisingStatistics.php |
— | — | @@ -0,0 +1,308 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if ( $IP === false ) { |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +} |
| 8 | +require( "$IP/maintenance/Maintenance.php" ); |
| 9 | + |
| 10 | +class PopulateFundraisingStatistics extends Maintenance { |
| 11 | + /** |
| 12 | + * DB slave |
| 13 | + * @var object |
| 14 | + */ |
| 15 | + protected $dbr; |
| 16 | + |
| 17 | + /** |
| 18 | + * DB master |
| 19 | + * @var object |
| 20 | + */ |
| 21 | + protected $dbw; |
| 22 | + |
| 23 | + /** |
| 24 | + * Valid operations and their execution methods for this script to perform |
| 25 | + * |
| 26 | + * Operations are passed in as options during run-time - only valid options, |
| 27 | + * which are defined here, can be executed. Valid operations are mapped here |
| 28 | + * to a corresponding method ( array( 'operation' => 'method' )) |
| 29 | + * @var array |
| 30 | + */ |
| 31 | + protected $operation_map = array( |
| 32 | + 'populatedays' => 'populateDays', |
| 33 | + 'populatefundraisers' => 'populateFundraisers', |
| 34 | + 'updatedays' => 'updateDays', |
| 35 | + ); |
| 36 | + |
| 37 | + /** |
| 38 | + * Operations to execute |
| 39 | + * @var array |
| 40 | + */ |
| 41 | + public $operations = array(); |
| 42 | + |
| 43 | + public function __construct() { |
| 44 | + parent::__construct(); |
| 45 | + $this->mDescription = "Populates the public reporting summary tables"; |
| 46 | + |
| 47 | + $this->addOption( 'op', 'The ContributionReporting stats gathering operation to run (e.g. "updatedays"). Can specify multiple operations, separated by comma.', true, true ); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Bootstrap this maintenance script |
| 52 | + * |
| 53 | + * Performs operations necessary for this maintenance script to run which |
| 54 | + * cannot or do not make sense to run in the constructor. |
| 55 | + */ |
| 56 | + public function bootstrap() { |
| 57 | + /** |
| 58 | + * Set user-specified operations to perform |
| 59 | + */ |
| 60 | + $operations = explode( ',', $this->getOption( 'op' ) ); |
| 61 | + // Check sanity of specified operations |
| 62 | + if ( !$this->checkOperations( $operations ) ) { |
| 63 | + $this->error( 'Invalid operation specified.', true ); |
| 64 | + } else { |
| 65 | + $this->operations = $operations; |
| 66 | + } |
| 67 | + |
| 68 | + // Set database objects |
| 69 | + $this->dbr = wfGetDB( DB_SLAVE ); |
| 70 | + $this->dbw = wfGetDB( DB_MASTER ); |
| 71 | + $this->dbpr = efContributionReportingReadConnection(); |
| 72 | + |
| 73 | + // Set timezone to UTC (contribution data will always be in UTC) |
| 74 | + date_default_timezone_set( 'UTC' ); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Check whether or not specified operations are valid. |
| 79 | + * |
| 80 | + * A specified operation is considered valid if it exists |
| 81 | + * as a key in the operation map. |
| 82 | + * |
| 83 | + * @param array $ops An array of operations to check |
| 84 | + * @return bool |
| 85 | + */ |
| 86 | + public function checkOperations( array $ops ) { |
| 87 | + foreach ( $ops as $operation ) { |
| 88 | + if ( !isset( $this->operation_map[ $operation ] ) ) { |
| 89 | + return false; |
| 90 | + } |
| 91 | + } |
| 92 | + return true; |
| 93 | + } |
| 94 | + |
| 95 | + public function execute() { |
| 96 | + // finish bootstrapping the script |
| 97 | + $this->bootstrap(); |
| 98 | + |
| 99 | + // execute requested operations |
| 100 | + foreach ( $this->operations as $operation ) { |
| 101 | + $method = $this->operation_map[ $operation ]; |
| 102 | + $this->$method(); |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Populate the donation stats for every day |
| 108 | + * |
| 109 | + * Note that these summaries exclude amounts that are not between the mimumum and maximum |
| 110 | + * donation amounts. This is because every once in a while we have to condense multiple |
| 111 | + * donations that may span several days into a single donation for CiviCRM consumption. |
| 112 | + */ |
| 113 | + public function populateDays() { |
| 114 | + global $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum; |
| 115 | + |
| 116 | + $begin = time(); |
| 117 | + $records = 0; |
| 118 | + $insertArray = array(); |
| 119 | + $this->output( "Writing data to public_reporting_days...\n" ); |
| 120 | + |
| 121 | + $conditions = array( |
| 122 | + 'converted_amount >= ' . intval( $egFundraiserStatisticsMinimum ), |
| 123 | + 'converted_amount <= ' . intval( $egFundraiserStatisticsMaximum ) |
| 124 | + ); |
| 125 | + |
| 126 | + // Get the data for a fundraiser |
| 127 | + $result = $this->dbpr->select( 'public_reporting', |
| 128 | + array( |
| 129 | + "DATE_FORMAT( FROM_UNIXTIME( received ),'%Y-%m-%d' ) AS date", |
| 130 | + 'sum( converted_amount ) AS total', |
| 131 | + 'count( * ) AS number', |
| 132 | + 'avg( converted_amount ) AS average', |
| 133 | + 'max( converted_amount ) AS maximum', |
| 134 | + ), |
| 135 | + $conditions, |
| 136 | + __METHOD__, |
| 137 | + array( |
| 138 | + 'ORDER BY' => 'received', |
| 139 | + 'GROUP BY' => "DATE_FORMAT( FROM_UNIXTIME( received ),'%Y-%m-%d' )" |
| 140 | + ) |
| 141 | + ); |
| 142 | + |
| 143 | + while ( $row = $this->dbpr->fetchRow( $result ) ) { |
| 144 | + // Add it to the insert array |
| 145 | + $insertArray[] = array( |
| 146 | + 'prd_date' => $row['date'], |
| 147 | + 'prd_total' => $row['total'], |
| 148 | + 'prd_number' => $row['number'], |
| 149 | + 'prd_average' => $row['average'], |
| 150 | + 'prd_maximum' => $row['maximum'], |
| 151 | + 'prd_insert_timestamp' => time(), |
| 152 | + ); |
| 153 | + $records++; |
| 154 | + } |
| 155 | + |
| 156 | + if ( $records > 0 ) { |
| 157 | + // Empty the table of previous totals |
| 158 | + $res = $this->dbw->delete( 'public_reporting_days', array( 1 ) ); |
| 159 | + // Insert the new totals |
| 160 | + $res = $this->dbw->insert( 'public_reporting_days', $insertArray, __METHOD__ ); |
| 161 | + // Wait for the databases to sync |
| 162 | + wfWaitForSlaves(); |
| 163 | + } |
| 164 | + |
| 165 | + $lag = time() - $begin; |
| 166 | + $this->output( "Inserted " . $records . " rows. ($lag seconds)\n" ); |
| 167 | + $this->output( "Done.\n" ); |
| 168 | + } |
| 169 | + |
| 170 | + /** |
| 171 | + * Populate the cumulative donation stats for all fundraisers |
| 172 | + * |
| 173 | + * Note that we do not build these stats from the daily summaries since the summaries exclude |
| 174 | + * amounts that are not between the minumum and maximum donation amounts. |
| 175 | + */ |
| 176 | + public function populateFundraisers() { |
| 177 | + global $egFundraiserStatisticsFundraisers; |
| 178 | + |
| 179 | + $begin = time(); |
| 180 | + $records = 0; |
| 181 | + $insertArray = array(); |
| 182 | + $this->output( "Writing data to public_reporting_fundraisers...\n" ); |
| 183 | + foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) { |
| 184 | + |
| 185 | + $conditions = array( |
| 186 | + 'received >= ' . $this->dbpr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $fundraiser['start'] ) ) ), |
| 187 | + 'received <= ' . $this->dbpr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $fundraiser['end'] ) + 24 * 60 * 60 ) ), |
| 188 | + ); |
| 189 | + |
| 190 | + // Get the total for a fundraiser |
| 191 | + $result = $this->dbpr->select( |
| 192 | + 'public_reporting', |
| 193 | + array( |
| 194 | + 'sum( converted_amount ) AS total', |
| 195 | + 'count( * ) AS number', |
| 196 | + 'avg( converted_amount ) AS average', |
| 197 | + 'max( converted_amount ) AS maximum', |
| 198 | + ), |
| 199 | + $conditions, |
| 200 | + __METHOD__ |
| 201 | + ); |
| 202 | + $row = $this->dbpr->fetchRow( $result ); |
| 203 | + |
| 204 | + // Add it to the insert array |
| 205 | + $insertArray[] = array( |
| 206 | + 'prf_id' => $fundraiser['id'], |
| 207 | + 'prf_total' => $row['total'], |
| 208 | + 'prf_number' => $row['number'], |
| 209 | + 'prf_average' => $row['average'], |
| 210 | + 'prf_maximum' => $row['maximum'], |
| 211 | + 'prf_insert_timestamp' => time(), |
| 212 | + ); |
| 213 | + |
| 214 | + $records++; |
| 215 | + } |
| 216 | + if ( $records > 0 ) { |
| 217 | + // Empty the table of previous totals |
| 218 | + $res = $this->dbw->delete( 'public_reporting_fundraisers', array( 1 ) ); |
| 219 | + // Insert the new totals |
| 220 | + $res = $this->dbw->insert( 'public_reporting_fundraisers', $insertArray, __METHOD__ ); |
| 221 | + // Wait for the databases to sync |
| 222 | + wfWaitForSlaves(); |
| 223 | + } |
| 224 | + $lag = time() - $begin; |
| 225 | + $this->output( "Inserted " . $records . " rows. ($lag seconds)\n" ); |
| 226 | + $this->output( "Done.\n" ); |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * Populate the donation stats for every day of the current fundraiser |
| 231 | + * |
| 232 | + * Note that if you are running more than one fundraiser at once, you'll want to use |
| 233 | + * populateDays instead of updateDays. |
| 234 | + * Note that these summaries exclude amounts that are not between the mimumum and maximum |
| 235 | + * donation amounts. This is because every once in a while we have to condense multiple |
| 236 | + * donations that may span several days into a single donation for CiviCRM consumption. |
| 237 | + */ |
| 238 | + public function updateDays() { |
| 239 | + global $egFundraiserStatisticsFundraisers, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum; |
| 240 | + |
| 241 | + $mostRecentFundraiser = end( $egFundraiserStatisticsFundraisers ); |
| 242 | + $start = $mostRecentFundraiser['start']; |
| 243 | + $end = $mostRecentFundraiser['end']; |
| 244 | + $begin = time(); |
| 245 | + $records = 0; |
| 246 | + $insertArray = array(); |
| 247 | + $this->output( "Writing data to public_reporting_days...\n" ); |
| 248 | + |
| 249 | + $conditions = array( |
| 250 | + 'received >= ' . $this->dbpr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $start ) ) ), |
| 251 | + 'received <= ' . $this->dbpr->addQuotes( wfTimestamp( TS_UNIX, strtotime( $end ) + 24 * 60 * 60 ) ), |
| 252 | + 'converted_amount >= ' . $egFundraiserStatisticsMinimum, |
| 253 | + 'converted_amount <= ' . $egFundraiserStatisticsMaximum |
| 254 | + ); |
| 255 | + |
| 256 | + // Get the data for a fundraiser |
| 257 | + $result = $this->dbpr->select( 'public_reporting', |
| 258 | + array( |
| 259 | + "DATE_FORMAT( FROM_UNIXTIME( received ),'%Y-%m-%d' ) AS date", |
| 260 | + 'sum( converted_amount ) AS total', |
| 261 | + 'count( * ) AS number', |
| 262 | + 'avg( converted_amount ) AS average', |
| 263 | + 'max( converted_amount ) AS maximum', |
| 264 | + ), |
| 265 | + $conditions, |
| 266 | + __METHOD__, |
| 267 | + array( |
| 268 | + 'ORDER BY' => 'received', |
| 269 | + 'GROUP BY' => "DATE_FORMAT( FROM_UNIXTIME( received ),'%Y-%m-%d' )" |
| 270 | + ) |
| 271 | + ); |
| 272 | + |
| 273 | + while ( $row = $this->dbpr->fetchRow( $result ) ) { |
| 274 | + // Add it to the insert array |
| 275 | + $insertArray[] = array( |
| 276 | + 'prd_date' => $row['date'], |
| 277 | + 'prd_total' => $row['total'], |
| 278 | + 'prd_number' => $row['number'], |
| 279 | + 'prd_average' => $row['average'], |
| 280 | + 'prd_maximum' => $row['maximum'], |
| 281 | + 'prd_insert_timestamp' => time(), |
| 282 | + ); |
| 283 | + $records++; |
| 284 | + } |
| 285 | + |
| 286 | + if ( $records > 0 ) { |
| 287 | + // Empty the table of previous totals for this fundraiser |
| 288 | + $res = $this->dbw->delete( |
| 289 | + 'public_reporting_days', |
| 290 | + array( |
| 291 | + 'prd_date >= ' . $this->dbpr->addQuotes( wfTimestamp( TS_DB, strtotime( $start ) ) ), |
| 292 | + 'prd_date <= ' . $this->dbpr->addQuotes( wfTimestamp( TS_DB, strtotime( $end ) ) ), |
| 293 | + ) |
| 294 | + ); |
| 295 | + // Insert the new totals |
| 296 | + $res = $this->dbw->insert( 'public_reporting_days', $insertArray, __METHOD__ ); |
| 297 | + // Wait for the databases to sync |
| 298 | + wfWaitForSlaves(); |
| 299 | + } |
| 300 | + |
| 301 | + $lag = time() - $begin; |
| 302 | + $this->output( "Updated " . $records . " rows. ($lag seconds)\n" ); |
| 303 | + $this->output( "Done.\n" ); |
| 304 | + } |
| 305 | + |
| 306 | +} |
| 307 | + |
| 308 | +$maintClass = "PopulateFundraisingStatistics"; |
| 309 | +require_once( DO_MAINTENANCE ); |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/PopulateFundraisingStatistics.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 310 | + native |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionTotal_body.php |
— | — | @@ -1,25 +1,35 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ContributionTotal extends SpecialPage { |
| 4 | +class ContributionTotal extends UnlistedSpecialPage { |
| 5 | + |
| 6 | + protected $sharedMaxAge = 300; // Cache for 5 minutes on the server side |
| 7 | + protected $maxAge = 300; // Cache for 5 minutes on the client side |
| 8 | + |
5 | 9 | function __construct() { |
6 | 10 | parent::__construct( 'ContributionTotal' ); |
7 | 11 | } |
8 | 12 | |
9 | 13 | function execute( $par ) { |
10 | | - global $wgRequest, $wgOut; |
| 14 | + global $wgRequest, $wgOut, $egFundraiserStatisticsFundraisers; |
11 | 15 | |
12 | 16 | wfLoadExtensionMessages( 'ContributionReporting' ); |
13 | 17 | |
14 | 18 | $this->setHeaders(); |
15 | 19 | |
16 | | - # Get request data from, e.g. |
17 | | - $start = intval( wfTimestampOrNull( TS_UNIX, $wgRequest->getVal( 'start' ) ) ); |
| 20 | + // Get request data |
| 21 | + $fundraiserId = $wgRequest->getText( 'fundraiser' ); |
18 | 22 | $action = $wgRequest->getText( 'action' ); |
19 | | - $fudgeFactor = $wgRequest->getInt( 'fudgefactor' ); |
| 23 | + $fudgeFactor = $wgRequest->getInt( 'adjustment' ); |
| 24 | + |
| 25 | + // If no fundraiser was specified, use the most recent |
| 26 | + if ( !$fundraiserId ) { |
| 27 | + $mostRecentFundraiser = end( $egFundraiserStatisticsFundraisers ); |
| 28 | + $fundraiserId = $mostRecentFundraiser['id']; |
| 29 | + } |
20 | 30 | |
21 | | - $output = efContributionReportingTotal( $start, $fudgeFactor ); |
| 31 | + $output = efContributionReportingTotal( $fundraiserId, $fudgeFactor ); |
22 | 32 | |
23 | | - header( 'Cache-Control: max-age=300,s-maxage=300' ); |
| 33 | + header( "Cache-Control: max-age=$this->maxAge,s-maxage=$this->sharedMaxAge" ); |
24 | 34 | if ( $action == 'raw' ) { |
25 | 35 | $wgOut->disable(); |
26 | 36 | echo $output; |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionTotal_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
27 | 37 | Merged /trunk/extensions/ContributionReporting/ContributionTotal_body.php:r105659,105757,105916,105965 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/patches/public-reporting-summaries.sql |
— | — | @@ -0,0 +1,21 @@ |
| 2 | +-- Create summary tables for fundraising statistics |
| 3 | + |
| 4 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/public_reporting_fundraisers ( |
| 5 | + `prf_id` varchar(32) NOT NULL, |
| 6 | + `prf_total` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000', |
| 7 | + `prf_number` int(11) NOT NULL DEFAULT '0', |
| 8 | + `prf_average` decimal(8,4) NOT NULL DEFAULT '0.0000', |
| 9 | + `prf_maximum` decimal(11,4) NOT NULL DEFAULT '0.0000', |
| 10 | + `prf_insert_timestamp` int(10) NOT NULL, |
| 11 | + PRIMARY KEY (prf_id) |
| 12 | +) /*$wgDBTableOptions*/; |
| 13 | + |
| 14 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/public_reporting_days ( |
| 15 | + `prd_date` date NOT NULL, |
| 16 | + `prd_total` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000', |
| 17 | + `prd_number` int(11) NOT NULL DEFAULT '0', |
| 18 | + `prd_average` decimal(8,4) unsigned NOT NULL DEFAULT '0.0000', |
| 19 | + `prd_maximum` decimal(11,4) unsigned NOT NULL DEFAULT '0.0000', |
| 20 | + `prd_insert_timestamp` int(10) NOT NULL, |
| 21 | + PRIMARY KEY (prd_date) |
| 22 | +) /*$wgDBTableOptions*/; |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/patches/public-reporting-summaries.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 23 | + native |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/DailyTotal_body.php |
— | — | @@ -6,13 +6,11 @@ |
7 | 7 | * @ingroup Extensions |
8 | 8 | */ |
9 | 9 | |
10 | | -class SpecialDailyTotal extends IncludableSpecialPage { |
| 10 | +class SpecialDailyTotal extends UnlistedSpecialPage { |
11 | 11 | |
12 | | - protected $sharedMaxAge = 600; // Cache for 10 minutes on the server side |
13 | | - protected $maxAge = 600; // Cache for 10 minutes on the client side |
| 12 | + protected $sharedMaxAge = 300; // Cache for 5 minutes on the server side |
| 13 | + protected $maxAge = 300; // Cache for 5 minutes on the client side |
14 | 14 | |
15 | | - /* Functions */ |
16 | | - |
17 | 15 | public function __construct() { |
18 | 16 | parent::__construct( 'DailyTotal' ); |
19 | 17 | } |
— | — | @@ -20,13 +18,12 @@ |
21 | 19 | public function execute( $sub ) { |
22 | 20 | global $wgRequest, $wgOut; |
23 | 21 | |
24 | | - $js = $wgRequest->getBool( 'js', false ); |
25 | | - |
| 22 | + $this->setHeaders(); |
| 23 | + |
| 24 | + // Get request data |
| 25 | + $action = $wgRequest->getText( 'action' ); |
| 26 | + $fudgeFactor = $wgRequest->getInt( 'adjustment' ); |
26 | 27 | $timezone = $wgRequest->getText( 'timezone', '0' ); |
27 | | - |
28 | | - /* Setup */ |
29 | | - $wgOut->disable(); |
30 | | - $this->sendHeaders(); |
31 | 28 | |
32 | 29 | $zoneList = array ( |
33 | 30 | '-12' => array( 'name' => 'Kwajalein', 'offset' => '-12:00' ), |
— | — | @@ -79,64 +76,68 @@ |
80 | 77 | } |
81 | 78 | |
82 | 79 | $setTimeZone = date_default_timezone_set( $timeZoneName ); |
83 | | - $start = date( 'Y-m-d' ); // Get the current date in the requested timezone |
84 | | - $total = $this->query( $timeZoneOffset, $start ); |
85 | | - |
86 | | - $content = "wgFundraisingDailyTotal = $total;"; |
87 | | - |
88 | | - if ( $js ) { |
89 | | - echo $content; |
| 80 | + $today = date( 'Y-m-d' ); // Get the current date in the requested timezone |
| 81 | + $output = $this->getTodaysTotal( $timeZoneOffset, $today, $fudgeFactor ); |
| 82 | + |
| 83 | + header( "Cache-Control: max-age=$this->maxAge,s-maxage=$this->sharedMaxAge" ); |
| 84 | + if ( $action == 'raw' ) { |
| 85 | + $wgOut->disable(); |
| 86 | + echo $output; |
90 | 87 | } else { |
91 | | - echo $total; |
| 88 | + $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
| 89 | + $wgOut->addHTML( $output ); |
92 | 90 | } |
93 | 91 | } |
94 | 92 | |
95 | 93 | /* Private Functions */ |
96 | 94 | |
97 | | - private function query( $timeZoneOffset, $start ) { |
| 95 | + /** |
| 96 | + * Get the total amount of money raised for today |
| 97 | + * @param string $timeZoneOffset The timezone to request the total for |
| 98 | + * @param string $today The current date in the requested time zone, e.g. '2011-12-16' |
| 99 | + * @param int $fudgeFactor How much to adjust the total by |
| 100 | + * @return integer |
| 101 | + */ |
| 102 | + private function getTodaysTotal( $timeZoneOffset, $today, $fudgeFactor = 0 ) { |
98 | 103 | global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout; |
99 | 104 | |
100 | | - $key = wfMemcKey( 'fundraiserstatistics', $timeZoneOffset, $start ); |
| 105 | + // Delete this block once there is timezone support in the populating script |
| 106 | + $setTimeZone = date_default_timezone_set( 'UTC' ); |
| 107 | + $today = date( 'Y-m-d' ); // Get the current date in UTC |
| 108 | + $timeZoneOffset = '+00:00'; |
| 109 | + |
| 110 | + $key = wfMemcKey( 'fundraiserdailytotal', $timeZoneOffset, $today, $fudgeFactor ); |
101 | 111 | $cache = $wgMemc->get( $key ); |
102 | 112 | if ( $cache != false && $cache != -1 ) { |
103 | 113 | return $cache; |
104 | 114 | } |
105 | 115 | |
106 | | - // We're only interested in donations from the past 2 days at most |
107 | | - $recentTime = time() - 60 * 60 * 48; |
| 116 | + // Use MediaWiki slave database |
| 117 | + $dbr = wfGetDB( DB_SLAVE ); |
108 | 118 | |
109 | | - // Use database |
110 | | - $dbr = efContributionReportingConnection(); |
111 | | - #$dbr = wfGetDB( DB_MASTER ); |
112 | | - $conditions = array( |
113 | | - 'received > ' . $recentTime, |
114 | | - 'converted_amount >= ' . $egFundraiserStatisticsMinimum, |
115 | | - 'converted_amount <= ' . $egFundraiserStatisticsMaximum, |
116 | | - "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$timeZoneOffset'),'%Y-%m-%d') = '$start'" |
117 | | - ); |
118 | | - |
119 | | - $select = $dbr->select( 'public_reporting', |
120 | | - array( |
121 | | - 'sum(converted_amount)' |
122 | | - ), |
123 | | - $conditions, |
| 119 | + $result = $dbr->select( |
| 120 | + 'public_reporting_days', |
| 121 | + 'round( prd_total ) AS total', |
| 122 | + array( 'prd_date' => $today ), |
124 | 123 | __METHOD__ |
125 | 124 | ); |
126 | | - $row = $dbr->fetchRow( $select ); |
127 | | - $total = $row['sum(converted_amount)']; |
128 | | - if ( !$total ) $total = 0; |
| 125 | + $row = $dbr->fetchRow( $result ); |
129 | 126 | |
| 127 | + if ( $row['total'] > 0 ) { |
| 128 | + $total = $row['total']; |
| 129 | + } else { |
| 130 | + $total = 0; |
| 131 | + } |
| 132 | + |
| 133 | + // Make sure the fudge factor is a number |
| 134 | + if ( is_nan( $fudgeFactor ) ) { |
| 135 | + $fudgeFactor = 0; |
| 136 | + } |
| 137 | + |
| 138 | + // Add the fudge factor to the total |
| 139 | + $total += $fudgeFactor; |
| 140 | + |
130 | 141 | $wgMemc->set( $key, $total, $egFundraiserStatisticsCacheTimeout ); |
131 | 142 | return $total; |
132 | 143 | } |
133 | | - |
134 | | - private function sendHeaders() { |
135 | | - global $wgJsMimeType; |
136 | | - header( "Content-type: $wgJsMimeType; charset=utf-8" ); |
137 | | - header( "Cache-Control: public, s-maxage=$this->sharedMaxAge, max-age=$this->maxAge" ); |
138 | | - } |
139 | | - |
140 | | - public function isListed(){ |
141 | | - return false; |
142 | | - } |
143 | 144 | } |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.i18n.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | // ContributionReporting and ContributionTotal |
17 | 17 | 'contributionreporting-desc' => 'Live reporting on the Wikimedia fundraiser', |
18 | 18 | 'contributiontotal' => 'Contribution total', |
| 19 | + 'dailytotal' => 'Daily total', |
19 | 20 | |
20 | 21 | 'contribstats-header' => '', |
21 | 22 | 'contribstats-footer' => '', |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.i18n.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
22 | 23 | Merged /trunk/extensions/ContributionReporting/ContributionReporting.i18n.php:r105965 |
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionStatistics_body.php |
— | — | @@ -24,6 +24,11 @@ |
25 | 25 | |
26 | 26 | public function execute( $sub ) { |
27 | 27 | global $wgOut,$egContributionStatisticsViewDays; |
| 28 | + |
| 29 | + # Emergency short cut until this can be changed to use cron-generated data |
| 30 | + # These queries are too expensive to run on demand. |
| 31 | + $wgOut->redirect( SpecialPage::getTitleFor( 'FundraiserStatistics' )->getFullURL() ); |
| 32 | + return; |
28 | 33 | |
29 | 34 | $this->evalDateRange(); |
30 | 35 | |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionStatistics_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
31 | 36 | Merged /trunk/extensions/ContributionReporting/ContributionStatistics_body.php:r105965,106362 |
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting |
___________________________________________________________________ |
Modified: svn:mergeinfo |
32 | 37 | Merged /trunk/extensions/ContributionReporting:r105641,105657,105659,105757,105916,105965,106136,106234,106239,106246,106287,106362 |