Merge branch '2.5.x' of github.com:sourcefabric/Airtime into 2.5.x

Conflicts:
	airtime_mvc/application/models/Show.php
This commit is contained in:
Albert Santoni 2013-12-13 16:12:26 -05:00
commit 346036a9ca
43 changed files with 43859 additions and 44094 deletions

View file

@ -1056,13 +1056,17 @@ SQL;
/**
* Calculates the percentage of a show scheduled given the start and end times in date/time format
* and the time_filled as the total time the schow is scheduled for in time format.
*
* TODO when using propel properly this should be a method on the propel show instance model.
**/
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled)
{
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
if ($durationSeconds != 0) { //Prevent division by zero if zero length show occurs.
$utcTimezone = new DatetimeZone("UTC");
$startDt = new DateTime($p_starts, $utcTimezone);
$endDt = new DateTime($p_ends, $utcTimezone);
$durationSeconds = intval($endDt->format("U")) - intval($startDt->format("U"));
$time_filled = Application_Common_DateHelper::playlistTimeToSeconds($p_time_filled);
if ($durationSeconds != 0) { //Prevent division by zero if the show duration somehow becomes zero.
$percent = ceil(( $time_filled / $durationSeconds) * 100);
} else {
$percent = 0;

View file

@ -164,43 +164,6 @@ SQL;
$this->_showInstance->getDbModifiedInstance();
}
public function correctScheduleStartTimes()
{
$con = Propel::getConnection();
$instance_id = $this->getShowInstanceId();
$sql = <<<SQL
SELECT starts
FROM cc_schedule
WHERE instance_id = :instanceId
ORDER BY starts LIMIT 1;
SQL;
$scheduleStarts = Application_Common_Database::prepareAndExecute( $sql,
array( ':instanceId' => $instance_id ), 'column' );
if ($scheduleStarts) {
$scheduleStartsEpoch = strtotime($scheduleStarts);
$showStartsEpoch = strtotime($this->getShowInstanceStart());
$diff = $showStartsEpoch - $scheduleStartsEpoch;
if ($diff != 0) {
$sql = <<<SQL
UPDATE cc_schedule
SET starts = starts + :diff1::INTERVAL SECOND,
ends = ends + :diff2::INTERVAL SECOND
WHERE instance_id = :instanceId
SQL;
Application_Common_Database::prepareAndExecute($sql,
array(
':diff1' => $diff,
':diff2' => $diff,
':instanceId' => $instance_id ), 'execute');
}
}
Application_Model_RabbitMq::PushSchedule();
}
/*
* @param $dateTime
* php Datetime object to add deltas to
@ -239,67 +202,6 @@ SQL;
return $newDateTime;
}
public function resizeShow($deltaDay, $deltaMin)
{
$con = Propel::getConnection();
$hours = $deltaMin / 60;
$hours = ($hours > 0) ? floor($hours) : ceil($hours);
$mins = abs($deltaMin % 60);
$today_timestamp = gmdate("Y-m-d H:i:s");
$starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd();
if (strtotime($today_timestamp) > strtotime($starts)) {
return _("can't resize a past show");
}
//$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$sql = "SELECT timestamp :ends + interval :deltaDays + interval :deltaTime";
$now_ends = Application_Common_Database::prepareAndExecute($sql,
array(':ends' => $ends,
':deltaDays' => "$deltaDay days",
':deltaTime' => "{$hours}:{$mins}"), 'column'
);
//only need to check overlap if show increased in size.
if (strtotime($now_ends) > strtotime($ends)) {
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
$utcEndDateTime = new DateTime($now_ends, new DateTimeZone("UTC"));
$overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime);
if (count($overlap) > 0) {
// TODO : fix ghetto error handling -- RG
return _("Should not overlap shows");
}
}
//with overbooking no longer need to check already scheduled content still fits.
//must update length of all rebroadcast instances.
if ($this->isRecorded()) {
$sql = <<<SQL
UPDATE cc_show_instances
SET ends = (ends + interval :deltaDays + interval :interval)
WHERE rebroadcast = 1
AND instance_id = :instanceId;
SQL;
Application_Common_Database::prepareAndExecute( $sql, array(
':deltaDays' => "$deltaDay days",
':interval' => "$hours:$mins",
':instanceId' => $this->_instanceId ), 'execute');
}
$this->setShowEnd($now_ends);
Application_Model_RabbitMq::PushSchedule();
}
/**
* Add a playlist as the last item of the current show.
*
@ -733,21 +635,6 @@ SQL;
return ($query !== false) ? $query : null;
}
public function getShowEndGapTime()
{
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
if (is_null($lastItemEnd)) {
$lastItemEnd = $this->getShowInstanceStart();
}
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
return ($diff < 0) ? 0 : $diff;
}
public static function GetLastShowInstance($p_timeNow)
{
$sql = <<<SQL