CC-3104: Timezone issues in the widget
For a previous ticket, I changed the code so that both "Today's Program" widget and "Now Playing" widget both use the liveInfoAction, but forgot that for "Now Playing" widget, it retrieves the shows within next 48 hours instead of within end of day today... Fixed by passing GET parameters to liveInfoAction, specify whether we want to retrieve shows within an interval or end of day. Also added a GET parameter for specifying the number of shows to display.
This commit is contained in:
parent
288fa86782
commit
276607c302
4 changed files with 45 additions and 9 deletions
|
@ -172,6 +172,21 @@ class ApiController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the currently playing show as well as upcoming shows.
|
||||
* Number of shows returned and the time interval in which to
|
||||
* get the next shows can be configured as post parameters.
|
||||
*
|
||||
* TODO: in the future, make interval length a parameter instead of hardcode to 48
|
||||
*
|
||||
* Possible parameters:
|
||||
* type - Can have values of "endofday" or "interval". If set to "endofday",
|
||||
* the function will retrieve shows from now to end of day.
|
||||
* If set to "interval", shows in the next 48 hours will be retrived.
|
||||
* Default is "interval".
|
||||
* limit - How many shows to retrieve
|
||||
* Default is "5".
|
||||
*/
|
||||
public function liveInfoAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||
|
@ -181,11 +196,24 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day
|
||||
|
||||
$request = $this->getRequest();
|
||||
$type = $request->getParam('type');
|
||||
if($type == "endofday") {
|
||||
// make GetNextShows use end of day
|
||||
$utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc();
|
||||
}
|
||||
|
||||
$limit = $request->getParam('limit');
|
||||
if($limit == "") {
|
||||
$limit = "5";
|
||||
}
|
||||
|
||||
$result = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd),
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
|
||||
|
@ -219,7 +247,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$result = array();
|
||||
for ($i=0; $i<7; $i++){
|
||||
$utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||
$shows = Application_Model_Show::GetNextShows($utcDayStart, 0, $utcDayEnd);
|
||||
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd);
|
||||
$utcDayStart = $utcDayEnd;
|
||||
|
||||
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
|
|
@ -84,7 +84,7 @@ class Application_Model_DateHelper
|
|||
|
||||
public static function GetDayEndTimestampInUtc($time = "") {
|
||||
$dayEndTimestamp = Application_Model_DateHelper::GetDayEndTimestamp($time);
|
||||
return Application_Model_DateHelper::ConvertToUtcDateTime($dayEndTimestamp);
|
||||
return Application_Model_DateHelper::ConvertToUtcDateTimeString($dayEndTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1556,7 +1556,7 @@ class Application_Model_Show {
|
|||
* @param String $timeEnd - interval end time (in UTC)
|
||||
* @return array - the next $limit number of shows within the time interval
|
||||
*/
|
||||
public static function GetNextShows($timeStart, $limit = 0, $timeEnd = "")
|
||||
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
|
@ -1577,7 +1577,7 @@ class Application_Model_Show {
|
|||
." ORDER BY si.starts";
|
||||
|
||||
// defaults to retrieve all shows within the interval if $limit not set
|
||||
if($limit != 0) {
|
||||
if($limit != "0") {
|
||||
$sql = $sql . " LIMIT $limit";
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,13 @@
|
|||
}
|
||||
|
||||
function getServerData(){
|
||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||
$.ajax({url: options.sourceDomain + "api/live-info/",
|
||||
data: {type:"endofday",limit:"5"},
|
||||
dataType: "jsonp",
|
||||
success:function(data) {
|
||||
processData(data);
|
||||
}, error:airtimeScheduleJsonpError});
|
||||
},
|
||||
error: airtimeScheduleJsonpError});
|
||||
setTimeout(getServerData, options.updatePeriod*1000);
|
||||
}
|
||||
});
|
||||
|
@ -130,9 +134,13 @@
|
|||
}
|
||||
|
||||
function getServerData(){
|
||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||
$.ajax({url: options.sourceDomain + "api/live-info/",
|
||||
data: {type:"interval",limit:"5"},
|
||||
dataType: "jsonp",
|
||||
success: function(data) {
|
||||
processData(data);
|
||||
}, error:airtimeScheduleJsonpError});
|
||||
},
|
||||
error: airtimeScheduleJsonpError});
|
||||
setTimeout(getServerData, options.updatePeriod*1000);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue