CC-5376: Sometimes schedule times don't get updated

This commit is contained in:
denise 2013-10-07 15:53:33 -04:00
parent 55254e88a5
commit 8a25d9cd2e
1 changed files with 24 additions and 23 deletions

View File

@ -17,6 +17,7 @@ class Application_Service_ShowService
private $oldShowTimezone; private $oldShowTimezone;
private $localShowStartHour; private $localShowStartHour;
private $localShowStartMin; private $localShowStartMin;
private $origCcShowDay;
public function __construct($showId=null, $showData=null, $isUpdate=false) public function __construct($showId=null, $showData=null, $isUpdate=false)
{ {
@ -126,11 +127,11 @@ class Application_Service_ShowService
*/ */
private function storeOrigLocalShowInfo() private function storeOrigLocalShowInfo()
{ {
$origShowDay = $this->ccShow->getFirstCcShowDay(); $this->origCcShowDay = $this->ccShow->getFirstCcShowDay();
$this->oldShowTimezone = $origShowDay->getDbTimezone(); $this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
$origStartTime = explode(":", $origShowDay->getDbStartTime()); $origStartTime = explode(":", $this->origCcShowDay->getDbStartTime());
$this->localShowStartHour = $origStartTime[0]; $this->localShowStartHour = $origStartTime[0];
$this->localShowStartMin = $origStartTime[1]; $this->localShowStartMin = $origStartTime[1];
} }
@ -185,6 +186,10 @@ class Application_Service_ShowService
//create new ccShowInstances //create new ccShowInstances
$this->delegateInstanceCreation($daysAdded); $this->delegateInstanceCreation($daysAdded);
if ($this->isUpdate) {
$this->adjustSchedule($showData);
}
$con->commit(); $con->commit();
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} catch (Exception $e) { } catch (Exception $e) {
@ -195,6 +200,20 @@ class Application_Service_ShowService
} }
} }
private function adjustSchedule($showData)
{
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstances = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->find();
$this->updateScheduleStartEndTimes($showData);
foreach ($ccShowInstances as $instance) {
$instance->updateScheduleStatus($con);
}
}
/** /**
* *
* Receives a cc_show id and determines whether to create a * Receives a cc_show id and determines whether to create a
@ -761,11 +780,9 @@ SQL;
return $endDate; return $endDate;
} }
private function applyShowStartEndDifference($showData) private function updateScheduleStartEndTimes($showData)
{ {
$showId = $this->ccShow->getDbId(); $showId = $this->ccShow->getDbId();
//CcShowDay object
$currentShowDay = $this->ccShow->getFirstCcShowDay();
//DateTime in show's local time //DateTime in show's local time
$newStartDateTime = new DateTime($showData["add_show_start_date"]." ". $newStartDateTime = new DateTime($showData["add_show_start_date"]." ".
@ -773,9 +790,8 @@ SQL;
new DateTimeZone($showData["add_show_timezone"])); new DateTimeZone($showData["add_show_timezone"]));
$diff = $this->calculateShowStartDiff($newStartDateTime, $diff = $this->calculateShowStartDiff($newStartDateTime,
$currentShowDay->getLocalStartDateAndTime()); $this->origCcShowDay->getLocalStartDateAndTime());
//$this->updateInstanceStartEndTime($diff);
$ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); $ccShowInstances = $this->ccShow->getFutureCcShowInstancess();
$instanceIds = array(); $instanceIds = array();
foreach ($ccShowInstances as $ccShowInstance) { foreach ($ccShowInstances as $ccShowInstance) {
@ -882,11 +898,6 @@ SQL;
$ccShowInstance->setDbRecord($showDay->getDbRecord()); $ccShowInstance->setDbRecord($showDay->getDbRecord());
$ccShowInstance->save(); $ccShowInstance->save();
if ($this->isUpdate) {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstance->updateScheduleStatus($con);
}
if ($this->isRebroadcast) { if ($this->isRebroadcast) {
$this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId()); $this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId());
} }
@ -969,11 +980,6 @@ SQL;
$ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbEnds($utcEndDateTime);
$ccShowInstance->setDbRecord($record); $ccShowInstance->setDbRecord($record);
$ccShowInstance->save(); $ccShowInstance->save();
if ($updateScheduleStatus) {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstance->updateScheduleStatus($con);
}
} }
if ($this->isRebroadcast) { if ($this->isRebroadcast) {
@ -1062,11 +1068,6 @@ SQL;
$ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbEnds($utcEndDateTime);
$ccShowInstance->setDbRecord($record); $ccShowInstance->setDbRecord($record);
$ccShowInstance->save(); $ccShowInstance->save();
if ($updateScheduleStatus) {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstance->updateScheduleStatus($con);
}
} }
if ($this->isRebroadcast) { if ($this->isRebroadcast) {