CC-5090: Unscheduled tracks are still marked at Scheduled in linked show
This commit is contained in:
parent
bfd525395a
commit
c173744929
4 changed files with 48 additions and 8 deletions
|
@ -20,7 +20,7 @@ SQL;
|
||||||
return (is_numeric($count) && ($count != '0'));
|
return (is_numeric($count) && ($count != '0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllFutureScheduledFiles()
|
public static function getAllFutureScheduledFiles($instanceId=null)
|
||||||
{
|
{
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT distinct(file_id)
|
SELECT distinct(file_id)
|
||||||
|
@ -29,6 +29,24 @@ WHERE ends > now() AT TIME ZONE 'UTC'
|
||||||
AND file_id is not null
|
AND file_id is not null
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
|
/* If an instance id gets passed into this function we need to check
|
||||||
|
* if it is a repeating show. If it is a repeating show, we need to
|
||||||
|
* check for any files scheduled in the future in the linked instances
|
||||||
|
* as well
|
||||||
|
*/
|
||||||
|
if (!is_null($instanceId)) {
|
||||||
|
$excludeIds = array();
|
||||||
|
$ccShow = CcShowInstancesQuery::create()
|
||||||
|
->findPk($instanceId)
|
||||||
|
->getCcShow();
|
||||||
|
if ($ccShow->isLinked()) {
|
||||||
|
foreach ($ccShow->getOtherInstances($instanceId) as $instance) {
|
||||||
|
$excludeIds[] = $instance->getDbId();
|
||||||
|
}
|
||||||
|
$sql .= " AND instance_id IN (".implode(",", $excludeIds).")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$files = Application_Common_Database::prepareAndExecute( $sql, array());
|
$files = Application_Common_Database::prepareAndExecute( $sql, array());
|
||||||
|
|
||||||
$real_files = array();
|
$real_files = array();
|
||||||
|
|
|
@ -1322,7 +1322,9 @@ SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setIsScheduled($p_scheduleItem, $p_status, $p_fileId=null) {
|
public static function setIsScheduled($p_scheduleItem, $p_status,
|
||||||
|
$p_fileId=null, $instanceId=null) {
|
||||||
|
|
||||||
if (is_null($p_fileId)) {
|
if (is_null($p_fileId)) {
|
||||||
$fileId = Application_Model_Schedule::GetFileId($p_scheduleItem);
|
$fileId = Application_Model_Schedule::GetFileId($p_scheduleItem);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1331,7 +1333,8 @@ SQL;
|
||||||
$file = self::RecallById($fileId);
|
$file = self::RecallById($fileId);
|
||||||
$updateIsScheduled = false;
|
$updateIsScheduled = false;
|
||||||
|
|
||||||
if (!is_null($fileId) && !in_array($fileId, Application_Model_Schedule::getAllFutureScheduledFiles())) {
|
if (!is_null($fileId) && !in_array($fileId,
|
||||||
|
Application_Model_Schedule::getAllFutureScheduledFiles($instanceId))) {
|
||||||
$file->_file->setDbIsScheduled($p_status)->save();
|
$file->_file->setDbIsScheduled($p_status)->save();
|
||||||
$updateIsScheduled = true;
|
$updateIsScheduled = true;
|
||||||
}
|
}
|
||||||
|
@ -1341,15 +1344,23 @@ SQL;
|
||||||
|
|
||||||
public static function updatePastFilesIsScheduled()
|
public static function updatePastFilesIsScheduled()
|
||||||
{
|
{
|
||||||
|
/* Retrieve files that are scheduled in the past OR that belong
|
||||||
|
* to a show that has ended. We need to check if the show has
|
||||||
|
* ended incase a track is overbooked, since that alone will
|
||||||
|
* indicate the show is still scheduled in the future
|
||||||
|
*/
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT file_id FROM cc_schedule
|
SELECT s.file_id, s.instance_id FROM cc_schedule AS s
|
||||||
WHERE ends < now() at time zone 'UTC'
|
LEFT JOIN cc_show_instances AS i
|
||||||
|
ON s.instance_id = i.id
|
||||||
|
WHERE s.ends < now() at time zone 'UTC'
|
||||||
|
OR i.ends < now() at time zone 'UTC'
|
||||||
SQL;
|
SQL;
|
||||||
$files = Application_Common_Database::prepareAndExecute($sql);
|
$files = Application_Common_Database::prepareAndExecute($sql);
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (!is_null($file['file_id'])) {
|
if (!is_null($file['file_id'])) {
|
||||||
self::setIsScheduled(null, false, $file['file_id']);
|
self::setIsScheduled(null, false, $file['file_id'], $file['instance_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,4 +189,12 @@ class CcShow extends BaseCcShow {
|
||||||
}
|
}
|
||||||
return $instanceIds;
|
return $instanceIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOtherInstances($instanceId)
|
||||||
|
{
|
||||||
|
return CcShowInstancesQuery::create()
|
||||||
|
->filterByCcShow($this)
|
||||||
|
->filterByDbId($instanceId, Criteria::NOT_IN)
|
||||||
|
->find();
|
||||||
|
}
|
||||||
} // CcShow
|
} // CcShow
|
||||||
|
|
|
@ -41,8 +41,11 @@ class Application_Service_SchedulerService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Enter description here ...
|
* Applies the show start difference to any scheduled items
|
||||||
* @param array $instanceIds
|
*
|
||||||
|
* @param $instanceIds
|
||||||
|
* @param $diff
|
||||||
|
* @param $newStart
|
||||||
*/
|
*/
|
||||||
public static function updateScheduleStartTime($instanceIds, $diff=null, $newStart=null)
|
public static function updateScheduleStartTime($instanceIds, $diff=null, $newStart=null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue