Merge branch 'saas' of https://github.com/sourcefabric/Airtime into saas
This commit is contained in:
commit
2f96885d65
|
@ -1291,27 +1291,36 @@ SQL;
|
||||||
return $updateIsScheduled;
|
return $updateIsScheduled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates the is_scheduled flag to false for tracks that are no longer
|
||||||
|
* scheduled in the future. We do this by checking the difference between
|
||||||
|
* all files scheduled in the future and all files with is_scheduled = true.
|
||||||
|
* The difference of the two result sets is what we need to update.
|
||||||
|
*/
|
||||||
public static function updatePastFilesIsScheduled()
|
public static function updatePastFilesIsScheduled()
|
||||||
{
|
{
|
||||||
/* Set the is_scheduled flag to false where it was true in the
|
$futureScheduledFilesSelectCriteria = new Criteria();
|
||||||
* past, and where tracks are not scheduled in the future and do
|
$futureScheduledFilesSelectCriteria->addSelectColumn(CcSchedulePeer::FILE_ID);
|
||||||
* not belong to a show that has not ended yet. We need to check
|
$futureScheduledFilesSelectCriteria->setDistinct();
|
||||||
* for show end times in case a track is overbooked, which would
|
$futureScheduledFilesSelectCriteria->add(CcSchedulePeer::ENDS, gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN);
|
||||||
* indicate it is still scheduled in the future
|
$stmt = CcSchedulePeer::doSelectStmt($futureScheduledFilesSelectCriteria);
|
||||||
*/
|
$filesScheduledInFuture = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||||
$sql = <<<SQL
|
|
||||||
UPDATE cc_files SET is_scheduled = false
|
$filesCurrentlySetWithIsScheduledSelectCriteria = new Criteria();
|
||||||
WHERE is_scheduled = true
|
$filesCurrentlySetWithIsScheduledSelectCriteria->addSelectColumn(CcFilesPeer::ID);
|
||||||
AND id NOT IN (
|
$filesCurrentlySetWithIsScheduledSelectCriteria->add(CcFilesPeer::IS_SCHEDULED, true);
|
||||||
SELECT s.file_id FROM cc_schedule AS s
|
$stmt = CcFilesPeer::doSelectStmt($filesCurrentlySetWithIsScheduledSelectCriteria);
|
||||||
LEFT JOIN cc_show_instances AS i
|
$filesCurrentlySetWithIsScheduled = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||||
ON s.instance_id = i.id
|
|
||||||
WHERE s.ends > now() at time zone 'UTC'
|
$diff = array_diff($filesCurrentlySetWithIsScheduled, $filesScheduledInFuture);
|
||||||
AND i.ends > now() at time zone 'UTC'
|
|
||||||
)
|
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
||||||
SQL;
|
$selectCriteria = new Criteria();
|
||||||
Application_Common_Database::prepareAndExecute($sql, array(),
|
$selectCriteria->add(CcFilesPeer::ID, $diff, Criteria::IN);
|
||||||
Application_Common_Database::EXECUTE);
|
$updateCriteria = new Criteria();
|
||||||
|
$updateCriteria->add(CcFilesPeer::IS_SCHEDULED, false);
|
||||||
|
BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue