CC-5151: Calendar -> Remove all content -> Does not update scheduled flag in library
Fixed so it doesn't update files that are scheduled in other shows
This commit is contained in:
parent
254ebb709e
commit
f3edc2bee6
|
@ -301,27 +301,41 @@ class Application_Service_SchedulerService
|
||||||
$instances[] = $ccShowInstance;
|
$instances[] = $ccShowInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the is_scheduled flag in cc_files to false
|
/* Get the file ids of the tracks we are about to delete
|
||||||
* We need to do this before we delete the scheduled items
|
* from cc_schedule. We need these so we can update the
|
||||||
|
* is_scheduled flag in cc_files
|
||||||
*/
|
*/
|
||||||
$ccSchedules = CcScheduleQuery::create()
|
$ccSchedules = CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||||
|
->setDistinct(CcSchedulePeer::FILE_ID)
|
||||||
->find();
|
->find();
|
||||||
$fileIds = array();
|
$fileIds = array();
|
||||||
foreach ($ccSchedules as $ccSchedule) {
|
foreach ($ccSchedules as $ccSchedule) {
|
||||||
$fileIds[] = $ccSchedule->getDbFileId();
|
$fileIds[] = $ccSchedule->getDbFileId();
|
||||||
}
|
}
|
||||||
$selectCriteria = new Criteria();
|
|
||||||
$selectCriteria->add(CcFilesPeer::ID, $fileIds, Criteria::IN);
|
|
||||||
$updateCriteria = new Criteria();
|
|
||||||
$updateCriteria->add(CcFilesPeer::IS_SCHEDULED, false);
|
|
||||||
BasePeer::doUpdate($selectCriteria, $updateCriteria, Propel::getConnection());
|
|
||||||
|
|
||||||
/* Clear out the schedule */
|
/* Clear out the schedule */
|
||||||
CcScheduleQuery::create()
|
CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
->filterByDbInstanceId($instanceIds, Criteria::IN)
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
|
/* Now that the schedule has been cleared we need to make
|
||||||
|
* sure we do not update the is_scheduled flag for tracks
|
||||||
|
* that are scheduled in other shows
|
||||||
|
*/
|
||||||
|
$futureScheduledFiles = Application_Model_Schedule::getAllFutureScheduledFiles();
|
||||||
|
foreach ($fileIds as $k => $v) {
|
||||||
|
if (in_array($v, $futureScheduledFiles)) {
|
||||||
|
unset($fileIds[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$selectCriteria = new Criteria();
|
||||||
|
$selectCriteria->add(CcFilesPeer::ID, $fileIds, Criteria::IN);
|
||||||
|
$updateCriteria = new Criteria();
|
||||||
|
$updateCriteria->add(CcFilesPeer::IS_SCHEDULED, false);
|
||||||
|
BasePeer::doUpdate($selectCriteria, $updateCriteria, Propel::getConnection());
|
||||||
|
|
||||||
Application_Model_RabbitMq::PushSchedule();
|
Application_Model_RabbitMq::PushSchedule();
|
||||||
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
|
||||||
foreach ($instances as $instance) {
|
foreach ($instances as $instance) {
|
||||||
|
|
Loading…
Reference in New Issue