r105485 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105484‎ | r105485 | r105486 >
Date:23:27, 7 December 2011
Author:awjrichards
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/ContributionReporting (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/ContributionReporting/FundraiserStatistics_body.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/ContributionReporting/modules/ext.fundraiserstatistics.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.php
@@ -41,30 +41,22 @@
4242 $wgAutoloadClasses['SpecialContributionStatistics'] = $dir . 'ContributionStatistics_body.php';
4343 $wgAutoloadClasses['SpecialFundraiserStatistics'] = $dir . 'FundraiserStatistics_body.php';
4444 $wgAutoloadClasses['SpecialContributionTrackingStatistics'] = $dir . 'ContributionTrackingStatistics_body.php';
 45+/*
4546 $wgAutoloadClasses['SpecialDailyTotal'] = $dir . 'DailyTotal_body.php';
4647 $wgAutoloadClasses['SpecialYearlyTotal'] = $dir . 'YearlyTotal_body.php';
4748 $wgAutoloadClasses['DisabledNotice'] = $dir . 'DisabledNotice_body.php';
 49+*/
4850
49 -/*
5051 $wgSpecialPages['ContributionHistory'] = 'ContributionHistory';
5152 $wgSpecialPages['ContributionTotal'] = 'ContributionTotal';
5253 $wgSpecialPages['ContributionStatistics'] = 'SpecialContributionStatistics';
5354 $wgSpecialPages['FundraiserStatistics'] = 'SpecialFundraiserStatistics';
5455 $wgSpecialPages['ContributionTrackingStatistics'] = 'SpecialContributionTrackingStatistics';
 56+/*
5557 $wgSpecialPages['DailyTotal'] = 'SpecialDailyTotal';
5658 $wgSpecialPages['YearlyTotal'] = 'SpecialYearlyTotal';
5759 */
5860
59 -// Temporarily redirect all pages to DisabledNotice
60 -$wgSpecialPages['DisabledNotice'] = 'DisabledNotice';
61 -$wgSpecialPages['ContributionHistory'] = 'DisabledNotice';
62 -$wgSpecialPages['ContributionTotal'] = 'DisabledNotice';
63 -$wgSpecialPages['ContributionStatistics'] = 'DisabledNotice';
64 -$wgSpecialPages['FundraiserStatistics'] = 'DisabledNotice';
65 -$wgSpecialPages['ContributionTrackingStatistics'] = 'DisabledNotice';
66 -$wgSpecialPages['DailyTotal'] = 'DisabledNotice';
67 -$wgSpecialPages['YearlyTotal'] = 'DisabledNotice';
68 -
6961 $wgSpecialPageGroups['ContributionHistory'] = 'contribution';
7062 $wgSpecialPageGroups['ContributionTotal'] = 'contribution';
7163 $wgSpecialPageGroups['ContributionStatistics'] = 'contribution';
@@ -115,6 +107,10 @@
116108 ),
117109 );
118110
 111+// The first year of statistics to make visible by default.
 112+// We normally don't show all of them by default, since it makes the chart extremely wide.
 113+$egFundraiserStatisticsFirstYearDefault = 2009;
 114+
119115 // Thesholds for fundraiser statistics
120116 $egFundraiserStatisticsMinimum = 1;
121117 $egFundraiserStatisticsMaximum = 10000;
@@ -229,6 +225,11 @@
230226
231227 # Output
232228 $output = $row['ttl'] ? $row['ttl'] : '0';
 229+
 230+ // Make sure fudge factor is a number
 231+ if ( is_nan( $fudgeFactor ) ) {
 232+ $fudgeFactor = 0;
 233+ }
233234
234235 $output += $fudgeFactor;
235236
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/ContributionReporting.php
___________________________________________________________________
Modified: svn:mergeinfo
236237 Merged /trunk/extensions/ContributionReporting/ContributionReporting.php:r105051,105064,105145,105214,105353,105454
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/FundraiserStatistics_body.php
@@ -1,6 +1,7 @@
22 <?php
33 /**
44 * Special Page for Contribution statistics extension
 5+ * This page displays charts and tables related to donation statistics.
56 *
67 * @file
78 * @ingroup Extensions
@@ -15,15 +16,22 @@
1617 }
1718
1819 public function execute( $sub ) {
19 - global $wgRequest, $wgOut, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers;
 20+ global $wgRequest, $wgOut, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers,
 21+ $egFundraiserStatisticsFirstYearDefault;
2022
 23+ // Figure out what years to display initially
2124 $showYear = array();
2225 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
23 - if ( $wgRequest->wasPosted() ) {
24 - $showYear[$fundraiser['id']] = $wgRequest->getCheck( 'toogle'.$fundraiser['id'] );
 26+ // You can override the years to display by default via the query string.
 27+ // For example, Special:FundraiserStatistics?2007=show&2010=hide
 28+ $yearOverride = $wgRequest->getVal( $fundraiser['id'] );
 29+ if ( $yearOverride === "hide" ) {
 30+ $showYear[$fundraiser['id']] = false;
 31+ } else if ( $yearOverride === "show" ) {
 32+ $showYear[$fundraiser['id']] = true;
2533 } else {
26 - // By default, show only the fundraising years after 2008
27 - if ( intval( $fundraiser['id'] ) > 2008 ) {
 34+ // By default, show only the recent fundraising years
 35+ if ( intval( $fundraiser['id'] ) >= $egFundraiserStatisticsFirstYearDefault ) {
2836 $showYear[$fundraiser['id']] = true;
2937 } else {
3038 $showYear[$fundraiser['id']] = false;
@@ -31,15 +39,12 @@
3240 }
3341 }
3442
35 - $this->timezone = $wgRequest->getText( 'timezone', '+0:00' );
36 -
3743 /* Configuration (this isn't totally static data, some of it gets built on the fly) */
3844
3945 $charts = array(
4046 'totals' => array(
4147 'data' => array(),
4248 'index' => 1,
43 - 'query' => 'dailyTotalMax',
4449 'precision' => 2,
4550 'label' => 'fundraiserstats-total',
4651 'max' => 1,
@@ -47,7 +52,6 @@
4853 'contributions' => array(
4954 'data' => array(),
5055 'index' => 2,
51 - 'query' => 'contributionsMax',
5256 'precision' => 0,
5357 'label' => 'fundraiserstats-contributions',
5458 'max' => 1,
@@ -55,7 +59,6 @@
5660 'averages' => array(
5761 'data' => array(),
5862 'index' => 3,
59 - 'query' => 'averagesMax',
6063 'precision' => 2,
6164 'label' => 'fundraiserstats-avg',
6265 'max' => 1,
@@ -63,7 +66,6 @@
6467 'maximums' => array(
6568 'data' => array(),
6669 'index' => 4,
67 - 'query' => 'maximumsMax',
6870 'precision' => 2,
6971 'label' => 'fundraiserstats-max',
7072 'max' => 1,
@@ -71,7 +73,6 @@
7274 'ytd' => array(
7375 'data' => array(),
7476 'index' => 5,
75 - 'query' => 'yearlyTotalMax',
7677 'precision' => 2,
7778 'label' => 'fundraiserstats-ytd',
7879 'max' => 1,
@@ -85,11 +86,30 @@
8687
8788 /* Display */
8889
89 - $wgOut->addWikiMsg('contribstats-header');
 90+ $wgOut->addWikiMsg( 'contribstats-header' ); // Header (typically empty)
 91+
 92+ // The $fundraisingData array contains all of the fundraising data in the following scheme:
 93+ // $fundraisingData[<fundraiserId>][<dayIndex>][<dataTypeIndex>]
 94+ $fundraisingData = array();
 95+
 96+ foreach ( $egFundraiserStatisticsFundraisers as $fundraiserIndex => $fundraiser ) {
 97+
 98+ // See if this is the most recent fundraiser or not
 99+ if ( $fundraiserIndex == count( $egFundraiserStatisticsFundraisers ) - 1 ) {
 100+ $mostRecent = true;
 101+ } else {
 102+ $mostRecent = false;
 103+ }
 104+
 105+ // Collect all the data
 106+ $fundraisingData[$fundraiser['id']] = $this->query( $mostRecent, $fundraiser['start'], $fundraiser['end'] );
 107+ }
 108+
90109 // Chart maximums
91 - foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
 110+ // We cycle through all the fundraisers with all the different chart types and collect the maximums.
 111+ foreach ( $fundraisingData as $fundraiser ) {
92112 foreach ( $charts as $name => $chart ) {
93 - $chartMax = $this->query( $charts[$name]['query'], $fundraiser['start'], $fundraiser['end'] );
 113+ $chartMax = $this->getMaximum( $fundraiser, $chart['index'] );
94114 if ( $chartMax > $charts[$name]['max'] ) {
95115 $charts[$name]['max'] = $chartMax;
96116 }
@@ -99,12 +119,25 @@
100120 foreach ( $charts as $name => $chart ) {
101121 $charts[$name]['factor'] = 300 / $chart['max'];
102122 }
 123+
103124 // HTML-time!
104 - $view = 0;
105 - $htmlViews = '';
 125+
 126+ // Each bar on the graph is associated with an individual data table. The ID linking the
 127+ // bar and the table is stored in $dataTableId.
 128+ $dataTableId = 0;
 129+ $dataTablesHtml = ''; // This will contain the HTML for all the data tables
106130 foreach ( $egFundraiserStatisticsFundraisers as $fundraiserIndex => $fundraiser ) {
107 - $days = $this->query( 'dailyTotals', $fundraiser['start'], $fundraiser['end'] );
108 - $mostRecentFundraiser = $fundraiserIndex == count( $egFundraiserStatisticsFundraisers ) - 1;
 131+
 132+ // Get all the daily data for a particular fundraiser
 133+ $days = $fundraisingData[$fundraiser['id']];
 134+
 135+ // See if this is the most recent fundraiser or not
 136+ if ( $fundraiserIndex == count( $egFundraiserStatisticsFundraisers ) - 1 ) {
 137+ $mostRecentFundraiser = true;
 138+ } else {
 139+ $mostRecentFundraiser = false;
 140+ }
 141+
109142 foreach ( $charts as $name => $chart ) {
110143 $column = 0;
111144 foreach( $days as $i => $day ) {
@@ -125,13 +158,13 @@
126159
127160 $height = $chart['factor'] * $day[$chart['index']];
128161 $style = "height:{$height}px;";
129 - if ( $showYear[$fundraiser['id']] !== true ) {
 162+ if ( !$showYear[$fundraiser['id']] ) {
130163 $style .= "display:none;";
131164 }
132165 $attributes = array(
133166 'style' => $style,
134167 'class' => "fundraiserstats-bar fundraiserstats-bar-{$fundraiser['id']}",
135 - 'rel' => "fundraiserstats-view-box-{$view}",
 168+ 'rel' => "fundraiserstats-view-box-{$dataTableId}",
136169 );
137170 if ( $mostRecentFundraiser && $i == count( $days ) -1 ) {
138171 $attributes['class'] .= ' fundraiserstats-current';
@@ -139,28 +172,31 @@
140173 $charts[$name]['data'][$column] .= Xml::tags(
141174 'td', array( 'valign' => 'bottom' ), Xml::element( 'div', $attributes, '', false )
142175 );
143 - $htmlView = Xml::openElement( 'tr' );
 176+
 177+ // Construct the data table for this day
 178+ $dataTable = Xml::openElement( 'tr' );
144179 $count = 0;
145180 foreach ( $charts as $subchart ) {
146 - $htmlView .= Xml::element(
 181+ $dataTable .= Xml::element(
147182 'td', array( 'width' => '16%', 'nowrap' => 'nowrap' ), wfMsg( $subchart['label'] )
148183 );
149 - $htmlView .= Xml::element(
 184+ $dataTable .= Xml::element(
150185 'td',
151186 array( 'width' => '16%', 'nowrap' => 'nowrap', 'align' => 'right' ),
152187 $wgLang->formatNum( number_format( $day[$subchart['index']], $subchart['precision'] ) )
153188 );
154189 if ( ++$count % 3 == 0 ) {
155 - $htmlView .= Xml::closeElement( 'tr' ) . Xml::openElement( 'tr' );
 190+ $dataTable .= Xml::closeElement( 'tr' ) . Xml::openElement( 'tr' );
156191 }
157192 }
158 - $htmlView .= Xml::closeElement( 'tr' );
159 - $htmlViews .= Xml::tags(
 193+ $dataTable .= Xml::closeElement( 'tr' );
 194+
 195+ $dataTablesHtml .= Xml::tags(
160196 'div',
161197 array(
162 - 'id' => 'fundraiserstats-view-box-' . $view,
 198+ 'id' => 'fundraiserstats-view-box-' . $dataTableId,
163199 'class' => 'fundraiserstats-view-box',
164 - 'style' => 'display: ' . ( $view == 0 ? 'block' : 'none' )
 200+ 'style' => 'display: ' . ( $dataTableId == 0 ? 'block' : 'none' )
165201 ),
166202 Xml::tags(
167203 'table',
@@ -171,7 +207,7 @@
172208 Xml::tags(
173209 'td',
174210 array( 'colspan' => 6 ),
175 - Xml::element( 'h3', array( 'style' => 'float:right;color:gray;' ), $day[0] ) .
 211+ Xml::element( 'h3', array( 'style' => 'float:right;color:gray;' ), $day[0] ) . // The date
176212 Xml::tags(
177213 'h3',
178214 array( 'style' => 'float:left;color:black;' ),
@@ -180,11 +216,11 @@
181217 Xml::element( 'div', array( 'style' => 'clear:both;' ), '', false )
182218 )
183219 ) .
184 - $htmlView
 220+ $dataTable
185221 )
186222 );
187223 $column++;
188 - $view++;
 224+ $dataTableId++;
189225 }
190226 }
191227 }
@@ -197,15 +233,12 @@
198234
199235 $years = wfMsg( 'fundraiserstats-show-years' ).'<br/>';
200236 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
201 - $years .= Xml::check( 'toogle'.$fundraiser['id'], $showYear[$fundraiser['id']], array( 'id' => 'bar-'.$fundraiser['id'], 'class' => 'yeartoggle' ) );
202 - $years .= Xml::label( $fundraiser['id'], 'toogle'.$fundraiser['id'] );
 237+ $years .= Xml::check( 'toggle'.$fundraiser['id'], $showYear[$fundraiser['id']], array( 'id' => 'bar-'.$fundraiser['id'], 'class' => 'yeartoggle' ) );
 238+ $years .= Xml::label( $fundraiser['id'], 'toggle'.$fundraiser['id'] );
203239 $years .= "<br/>";
204240 }
205241 $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configholder' ) ) );
206242 $wgOut->addHTML( $years );
207 - // TODO: Fix timezone feature to work with caching correctly.
208 - // $wgOut->addHTML( wfMsg( 'fundraiserstats-time-zone' ).'<br/>' );
209 - // $wgOut->addHTML( '&#160;'.Xml::listDropDown( 'timezone', $this->dropDownList( range ( -12, 14, 1 ) ), '', $this->timezone, '', 1 ).' '.wfMsg( 'fundraiserstats-utc' ) );
210243 $wgOut->addHTML( Xml::closeElement( 'div' ) );
211244
212245 $wgOut->addHTML( Xml::closeElement( 'form' ) );
@@ -213,11 +246,13 @@
214247 // Instructions
215248 $wgOut->addWikiMsg( 'fundraiserstats-instructions' );
216249
 250+ $chartsHtml = ''; // This will contain the HTML for all of the bar charts and tabs
 251+
217252 // Tabs
 253+ $chartsHtml .= Xml::openElement( 'div', array( 'class' => 'fundraiserstats-chart-tabs' ) );
218254 $first = true;
219 - $htmlCharts = Xml::openElement( 'div', array( 'class' => 'fundraiserstats-chart-tabs' ) );
220255 foreach ( $charts as $chart => $columns ) {
221 - $htmlCharts .= Xml::tags(
 256+ $chartsHtml .= Xml::tags(
222257 'div',
223258 array(
224259 'id' => "fundraiserstats-chart-{$chart}-tab",
@@ -228,11 +263,12 @@
229264 );
230265 $first = false;
231266 }
232 - $htmlCharts .= Xml::closeElement( 'div' );
 267+ $chartsHtml .= Xml::closeElement( 'div' );
 268+
233269 // Charts
234270 $first = true;
235271 foreach ( $charts as $name => $chart ) {
236 - $htmlCharts .= Xml::tags(
 272+ $chartsHtml .= Xml::tags(
237273 'div',
238274 array(
239275 'id' => "fundraiserstats-chart-{$name}",
@@ -247,7 +283,8 @@
248284 );
249285 $first = false;
250286 }
251 - // Output
 287+
 288+ // Output everything
252289 $wgOut->addHTML(
253290 Xml::tags(
254291 'table',
@@ -256,23 +293,36 @@
257294 'cellspacing' => 0,
258295 'border' => 0
259296 ),
260 - Xml::tags( 'tr', null, Xml::tags( 'td', null, $htmlCharts ) ) .
261 - Xml::tags( 'tr', null, Xml::tags( 'td', null, $htmlViews ) )
 297+ Xml::tags( 'tr', null, Xml::tags( 'td', null, $chartsHtml ) ) .
 298+ Xml::tags( 'tr', null, Xml::tags( 'td', null, $dataTablesHtml ) )
262299 )
263300 );
264 - $wgOut->addWikiMsg('contribstats-footer');
 301+
 302+ $wgOut->addWikiMsg( 'contribstats-footer' ); // Footer (typically empty)
265303 }
266304
267305 /* Private Functions */
268306
269 - private function query( $type, $start, $end ) {
 307+ /**
 308+ * Retrieve the donation data from the database
 309+ *
 310+ * @param boolean $mostRecent Is this query for the most recent fundraiser?
 311+ * @param string $start The start date for a fundraiser
 312+ * @param string $end The end date for a fundraiser
 313+ * @return an array of results or null
 314+ */
 315+ private function query( $mostRecent, $start, $end ) {
270316 global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
271317
272 - $key = wfMemcKey( 'fundraiserstatistics', $type, $start, $end );
 318+ // Conctruct the key for memcached
 319+ $key = wfMemcKey( 'fundraiserstatistics', $start, $end );
 320+
 321+ // If result exists in memcached, use that
273322 $cache = $wgMemc->get( $key );
274323 if ( $cache != false && $cache != -1 ) {
275324 return $cache;
276325 }
 326+
277327 // Use database
278328 $dbr = efContributionReportingConnection();
279329 $conditions = array(
@@ -281,99 +331,60 @@
282332 'converted_amount >= ' . $egFundraiserStatisticsMinimum,
283333 'converted_amount <= ' . $egFundraiserStatisticsMaximum
284334 );
285 - switch ( $type ) {
286 - case 'dailyTotals':
287 - $select = $dbr->select( 'public_reporting',
288 - array(
289 - "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')",
290 - 'sum(converted_amount)',
291 - 'count(*)',
292 - 'avg(converted_amount)',
293 - 'max(converted_amount)',
294 - ),
295 - $conditions,
296 - __METHOD__ . '-dailyTotals',
297 - array(
298 - 'ORDER BY' => 'received',
299 - 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
300 - )
301 - );
302 - $result = array();
303 - $ytd = 0;
304 - while ( $row = $dbr->fetchRow( $select ) ) {
305 - $row[] = $ytd += $row[1]; // YTD
306 - $result[] = $row;
307 - }
308 - break;
309 - case 'dailyTotalMax':
310 - $result = $dbr->selectField( 'public_reporting',
311 - array( 'sum(converted_amount) as sum' ),
312 - $conditions,
313 - __METHOD__ . '-dailyTotalMax',
314 - array(
315 - 'ORDER BY' => 'sum DESC',
316 - 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
317 - )
318 - );
319 - break;
320 - case 'yearlyTotalMax':
321 - $result = $dbr->selectField( 'public_reporting',
322 - array( 'sum(converted_amount) as sum' ),
323 - $conditions,
324 - __METHOD__ . '-yearlyTotalMax'
325 - );
326 - break;
327 - case 'contributionsMax':
328 - $result = $dbr->selectField( 'public_reporting',
329 - array( 'count(converted_amount) as sum' ),
330 - $conditions,
331 - __METHOD__ . '-contributionsMax',
332 - array(
333 - 'ORDER BY' => 'sum DESC',
334 - 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
335 - )
336 - );
337 - break;
338 - case 'averagesMax':
339 - $result = $dbr->selectField( 'public_reporting',
340 - array( 'avg(converted_amount) as sum' ),
341 - $conditions,
342 - __METHOD__ . '-averagesMax',
343 - array(
344 - 'ORDER BY' => 'sum DESC',
345 - 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
346 - )
347 - );
348 - break;
349 - case 'maximumsMax':
350 - $result = $dbr->selectField( 'public_reporting',
351 - array( 'max(converted_amount) as sum' ),
352 - $conditions,
353 - __METHOD__ . '-maximumsMax',
354 - array(
355 - 'ORDER BY' => 'sum DESC',
356 - 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
357 - )
358 - );
359 - break;
 335+
 336+ // Get the data for a fundraiser
 337+ $select = $dbr->select( 'public_reporting',
 338+ array(
 339+ "DATE_FORMAT(FROM_UNIXTIME(received),'%Y-%m-%d')",
 340+ 'sum(converted_amount)',
 341+ 'count(*)',
 342+ 'avg(converted_amount)',
 343+ 'max(converted_amount)',
 344+ ),
 345+ $conditions,
 346+ __METHOD__,
 347+ array(
 348+ 'ORDER BY' => 'received',
 349+ 'GROUP BY' => "DATE_FORMAT(FROM_UNIXTIME(received),'%Y-%m-%d')"
 350+ )
 351+ );
 352+ $result = array();
 353+ $ytd = 0;
 354+ while ( $row = $dbr->fetchRow( $select ) ) {
 355+ // Insert the year-to-date amount as a record in the row (existing $ytd + sum)
 356+ $row[5] = $ytd += $row[1];
 357+ $result[] = $row;
360358 }
 359+
361360 if ( isset( $result ) ) {
362 - $wgMemc->set( $key, $result, $egFundraiserStatisticsCacheTimeout );
 361+ // Store the result in memcached.
 362+ // If it's the most recent fundraiser, cache for a short period of time, otherwise
 363+ // cache for 24 hours (since the query is expensive).
 364+ if ( $mostRecent ) {
 365+ $wgMemc->set( $key, $result, $egFundraiserStatisticsCacheTimeout );
 366+ } else {
 367+ $wgMemc->set( $key, $result, 86400 );
 368+ }
363369 return $result;
364370 }
365371 return null;
366372 }
367 -
 373+
368374 /**
369 - * @param $values
370 - * @return string
 375+ * Given a particular index, find the maximum for all values in a 2D array with that particular
 376+ * index as the 2nd key.
 377+ *
 378+ * @param array $fundraiserDays A 2D array of daily data for a particular fundraiser
 379+ * @param integer $comparisonIndex The index to find the maximum for
 380+ * @return an integer
371381 */
372 - private function dropDownList ( $values ) {
373 - $dropDown = '';
374 - foreach ( $values as $value ) {
375 - if ( $value >= 0 ) $dropDown .= '+';
376 - $dropDown .= "$value:00\n";
 382+ private function getMaximum( $fundraiserDays, $comparisonIndex ) {
 383+ $max = 0;
 384+ foreach( $fundraiserDays as $day ) {
 385+ if ( $day[$comparisonIndex] > $max ) {
 386+ $max = $day[$comparisonIndex];
 387+ }
377388 }
378 - return $dropDown;
 389+ return $max;
379390 }
380391 }
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting/FundraiserStatistics_body.php
___________________________________________________________________
Modified: svn:mergeinfo
381392 Merged /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php:r105051,105064,105145,105214,105353,105454
Index: branches/wmf/1.18wmf1/extensions/ContributionReporting/modules/ext.fundraiserstatistics.js
@@ -33,9 +33,11 @@
3434 $j( '.fundraiserstats-current' ).each( function() {
3535 replaceView( $j(this).attr( 'rel' ) )
3636 } );
 37+ // When someone clicks on a year, hide or show that year in the chart
3738 $j( '#configholder .yeartoggle' ).click( function() {
3839 $j('.fundraiserstats-'+$j(this).attr( 'id' )).toggle();
3940 } );
 41+ // When someone clicks on Customize, display pop-up menu and change arrow icon.
4042 $j( '#configtoggle' ).click( function() {
4143 $j('#configholder').toggle();
4244 if ($j( '#configtoggle a' ).css( 'background-position' ) == '0px -18px') {
@@ -44,8 +46,5 @@
4547 $j( '#configtoggle a' ).css( 'background-position','0px -18px' );
4648 }
4749 } );
48 - $j( '#timezone' ).change( function() {
49 - $j('#configform').submit();
50 - } );
5150
5251 } );
Property changes on: branches/wmf/1.18wmf1/extensions/ContributionReporting
___________________________________________________________________
Modified: svn:mergeinfo
5352 Merged /trunk/extensions/ContributionReporting:r105051,105064,105145,105214,105353,105454

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105051removing timezone code, renaming some poorly named variables, adding commentskaldari03:43, 3 December 2011
r105064better commentkaldari06:24, 3 December 2011
r105145rewriting FundraisingStatistics to use 1 query instead of 6, and heavily cach...kaldari02:12, 5 December 2011
r105214uncommenting cacheingkaldari20:11, 5 December 2011
r105353turning off the new special pages until new data collection system is in placekaldari21:15, 6 December 2011
r105454make sure fudge factor is number (again) to be safekaldari19:40, 7 December 2011

Status & tagging log