r103996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103995‎ | r103996 | r103997 >
Date:01:00, 23 November 2011
Author:kaldari
Status:ok
Tags:
Comment:
mapping to both name and offset
Modified paths:
  • /trunk/extensions/ContributionReporting/DailyTotal_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/DailyTotal_body.php
@@ -22,84 +22,65 @@
2323
2424 $js = $wgRequest->getBool( 'js', false );
2525
26 - $timezone = $wgRequest->getText( 'timezone', '0:00' );
 26+ $timezone = $wgRequest->getText( 'timezone', '0' );
2727
2828 /* Setup */
2929 $wgOut->disable();
3030 $this->sendHeaders();
3131
3232 $zoneList = array (
33 - '-12:00' => 'Kwajalein',
34 - '-11:00' => 'Pacific/Midway',
35 - '-10:00' => 'Pacific/Honolulu',
36 - '-9:00' => 'America/Anchorage',
37 - '-09:00' => 'America/Anchorage',
38 - '-8:00' => 'America/Los_Angeles',
39 - '-08:00' => 'America/Los_Angeles',
40 - '-7:00' => 'America/Denver',
41 - '-07:00' => 'America/Denver',
42 - '-6:00' => 'America/Tegucigalpa',
43 - '-06:00' => 'America/Tegucigalpa',
44 - '-5:00' => 'America/New_York',
45 - '-05:00' => 'America/New_York',
46 - '-4:30' => 'America/Caracas',
47 - '-04:30' => 'America/Caracas',
48 - '-4:00' => 'America/Halifax',
49 - '-04:00' => 'America/Halifax',
50 - '-3:30' => 'America/St_Johns',
51 - '-03:30' => 'America/St_Johns',
52 - '-3:00' => 'America/Sao_Paulo',
53 - '-03:00' => 'America/Sao_Paulo',
54 - '-2:00' => 'Atlantic/South_Georgia',
55 - '-02:00' => 'Atlantic/South_Georgia',
56 - '-1:00' => 'Atlantic/Azores',
57 - '-01:00' => 'Atlantic/Azores',
58 - '0:00' => 'UTC',
59 - '00:00' => 'UTC',
60 - '1:00' => 'Europe/Belgrade',
61 - '01:00' => 'Europe/Belgrade',
62 - '2:00' => 'Europe/Minsk',
63 - '02:00' => 'Europe/Minsk',
64 - '3:00' => 'Asia/Kuwait',
65 - '03:00' => 'Asia/Kuwait',
66 - '3:30' => 'Asia/Tehran',
67 - '03:30' => 'Asia/Tehran',
68 - '4:00' => 'Asia/Muscat',
69 - '04:00' => 'Asia/Muscat',
70 - '5:00' => 'Asia/Yekaterinburg',
71 - '05:00' => 'Asia/Yekaterinburg',
72 - '5:30' => 'Asia/Kolkata',
73 - '05:30' => 'Asia/Kolkata',
74 - '5:45' => 'Asia/Katmandu',
75 - '05:45' => 'Asia/Katmandu',
76 - '6:00' => 'Asia/Dhaka',
77 - '06:00' => 'Asia/Dhaka',
78 - '6:30' => 'Asia/Rangoon',
79 - '06:30' => 'Asia/Rangoon',
80 - '7:00' => 'Asia/Krasnoyarsk',
81 - '07:00' => 'Asia/Krasnoyarsk',
82 - '8:00' => 'Asia/Brunei',
83 - '08:00' => 'Asia/Brunei',
84 - '9:00' => 'Asia/Seoul',
85 - '09:00' => 'Asia/Seoul',
86 - '9:30' => 'Australia/Darwin',
87 - '09:30' => 'Australia/Darwin',
88 - '10:00' => 'Australia/Canberra',
89 - '11:00' => 'Asia/Magadan',
90 - '12:00' => 'Pacific/Fiji',
91 - '13:00' => 'Pacific/Tongatapu',
 33+ '-12' => array( 'name' => 'Kwajalein', 'offset' => '-12:00' ),
 34+ '-11' => array( 'name' => 'Pacific/Midway', 'offset' => '-11:00' ),
 35+ '-10' => array( 'name' => 'Pacific/Honolulu', 'offset' => '-10:00' ),
 36+ '-9' => array( 'name' => 'America/Anchorage', 'offset' => '-09:00' ),
 37+ '-8' => array( 'name' => 'America/Los_Angeles', 'offset' => '-08:00' ),
 38+ '-7' => array( 'name' => 'America/Denver', 'offset' => '-07:00' ),
 39+ '-6' => array( 'name' => 'America/Tegucigalpa', 'offset' => '-06:00' ),
 40+ '-5' => array( 'name' => 'America/New_York', 'offset' => '-05:00' ),
 41+ '-4.5' => array( 'name' => 'America/Caracas', 'offset' => '-04:30' ),
 42+ '-4' => array( 'name' => 'America/Halifax', 'offset' => '-04:00' ),
 43+ '-3.5' => array( 'name' => 'America/St_Johns', 'offset' => '-03:30' ),
 44+ '-3' => array( 'name' => 'America/Sao_Paulo', 'offset' => '-03:00' ),
 45+ '-2' => array( 'name' => 'Atlantic/South_Georgia', 'offset' => '-02:00' ),
 46+ '-1' => array( 'name' => 'Atlantic/Azores', 'offset' => '-01:00' ),
 47+ '0' => array( 'name' => 'UTC', 'offset' => '+00:00' ),
 48+ '1' => array( 'name' => 'Europe/Belgrade', 'offset' => '+01:00' ),
 49+ '2' => array( 'name' => 'Europe/Minsk', 'offset' => '+02:00' ),
 50+ '3' => array( 'name' => 'Asia/Kuwait', 'offset' => '+03:00' ),
 51+ '3.5' => array( 'name' => 'Asia/Tehran', 'offset' => '+03:30' ),
 52+ '4' => array( 'name' => 'Asia/Muscat', 'offset' => '+04:00' ),
 53+ '5' => array( 'name' => 'Asia/Yekaterinburg', 'offset' => '+05:00' ),
 54+ '5.5' => array( 'name' => 'Asia/Kolkata', 'offset' => '+05:30' ),
 55+ '5.75' => array( 'name' => 'Asia/Katmandu', 'offset' => '+05:45' ),
 56+ '6' => array( 'name' => 'Asia/Dhaka', 'offset' => '+06:00' ),
 57+ '6.5' => array( 'name' => 'Asia/Rangoon', 'offset' => '+06:30' ),
 58+ '7' => array( 'name' => 'Asia/Krasnoyarsk', 'offset' => '+07:00' ),
 59+ '8' => array( 'name' => 'Asia/Brunei', 'offset' => '+08:00' ),
 60+ '9' => array( 'name' => 'Asia/Seoul', 'offset' => '+09:00' ),
 61+ '9.5' => array( 'name' => 'Australia/Darwin', 'offset' => '+09:30' ),
 62+ '10' => array( 'name' => 'Australia/Canberra', 'offset' => '+10:00' ),
 63+ '11' => array( 'name' => 'Asia/Magadan', 'offset' => '+11:00' ),
 64+ '12' => array( 'name' => 'Pacific/Fiji', 'offset' => '+12:00' ),
 65+ '13' => array( 'name' => 'Pacific/Tongatapu', 'offset' => '+13:00' ),
9266 );
9367
94 - // Translate offset to timezone name for PHP
 68+ // Translate timezone param to timezone name for PHP
9569 if ( array_key_exists( $timezone, $zoneList ) ) {
96 - $timeZoneName = $zoneList[$timezone];
 70+ $timeZoneName = $zoneList[$timezone]['name'];
9771 } else {
9872 $timeZoneName = 'UTC';
9973 }
10074
 75+ // Translate timezone param to timezone offset for MySQL
 76+ if ( array_key_exists( $timezone, $zoneList ) ) {
 77+ $timeZoneOffset = $zoneList[$timezone]['offset'];
 78+ } else {
 79+ $timeZoneOffset = '+00:00';
 80+ }
 81+
10182 $setTimeZone = date_default_timezone_set( $timeZoneName );
10283 $start = date( 'Y-m-d' ); // Get the current date in the requested timezone
103 - $total = $this->query( $timezone, $start );
 84+ $total = $this->query( $timeZoneOffset, $start );
10485
10586 $content = "wgFundraisingDailyTotal = $total;";
10687
@@ -112,10 +93,10 @@
11394
11495 /* Private Functions */
11596
116 - private function query( $timezone, $start ) {
 97+ private function query( $timeZoneOffset, $start ) {
11798 global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
11899
119 - $key = wfMemcKey( 'fundraiserstatistics', $timezone, $start );
 100+ $key = wfMemcKey( 'fundraiserstatistics', $timeZoneOffset, $start );
120101 $cache = $wgMemc->get( $key );
121102 if ( $cache != false && $cache != -1 ) {
122103 return $cache;
@@ -127,7 +108,7 @@
128109 $conditions = array(
129110 'converted_amount >= ' . $egFundraiserStatisticsMinimum,
130111 'converted_amount <= ' . $egFundraiserStatisticsMaximum,
131 - "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$timezone'),'%Y-%m-%d') = '$start'"
 112+ "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$timeZoneOffset'),'%Y-%m-%d') = '$start'"
132113 );
133114
134115 $select = $dbr->select( 'public_reporting',

Follow-up revisions

RevisionCommit summaryAuthorDate
r103998MFT r103884, r103947, r103959, r103967, r103991, r103996awjrichards01:24, 23 November 2011
r104000MFT r103884, r103947, r103959, r103967, r103991, r103996awjrichards01:51, 23 November 2011

Status & tagging log