CC-3534 : Check Scheduling Edge Cases

extracting out error checking in scheduling, added created column to cc_showinstances
This commit is contained in:
Naomi Aro 2012-03-28 14:23:25 +02:00
parent b70773489a
commit 4904a16ebb
13 changed files with 282 additions and 184 deletions

View File

@ -206,9 +206,6 @@ class ShowbuilderController extends Zend_Controller_Action
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
@ -251,11 +248,11 @@ class ShowbuilderController extends Zend_Controller_Action
$request = $this->getRequest();
$mediaItems = $request->getParam("mediaIds", array());
$scheduledIds = $request->getParam("schedIds", array());
$scheduledItems = $request->getParam("schedIds", array());
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduledIds, $mediaItems);
$scheduler->scheduleAfter($scheduledItems, $mediaItems);
}
catch (OutDatedScheduleException $e) {
$this->view->error = $e->getMessage();
@ -297,12 +294,12 @@ class ShowbuilderController extends Zend_Controller_Action
public function scheduleMoveAction() {
$request = $this->getRequest();
$selectedItem = $request->getParam("selectedItem");
$selectedItems = $request->getParam("selectedItem");
$afterItem = $request->getParam("afterItem");
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->moveItem($selectedItem, $afterItem);
$scheduler->moveItem($selectedItems, $afterItem);
}
catch (OutDatedScheduleException $e) {
$this->view->error = $e->getMessage();
@ -324,46 +321,4 @@ class ShowbuilderController extends Zend_Controller_Action
$showInstance = $request->getParam("instanceId");
}
/*
* make sure any incoming requests for scheduling are ligit.
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function filterSelected($items) {
$allowed = array();
$user = Application_Model_User::GetCurrentUser();
$type = $user->getType();
//item must be within the host's show.
if ($type === UTYPE_HOST) {
$hosted = CcShowHostsQuery::create()
->filterByDbHost($user->getId())
->find();
$allowed_shows = array();
foreach ($hosted as $host) {
$allowed_shows[] = $host->getDbShow();
}
for ($i = 0; $i < count($items); $i++) {
$instance = $items[$i]["instance"];
if (in_array($instance, $allowed_shows)) {
$allowed[] = $items[$i];
}
}
$this->view->shows = $res;
}
//they can schedule anything.
else if ($type === UTYPE_ADMIN || $type === UTYPE_PROGRAM_MANAGER) {
$allowed = $items;
}
return $allowed;
}
}

View File

@ -15,9 +15,6 @@ class Application_Form_Preferences extends Zend_Form
$general_pref = new Application_Form_GeneralPreferences();
$this->addSubForm($general_pref, 'preferences_general');
$livestream_pref = new Application_Form_LiveStreamingPreferences();
$this->addSubForm($livestream_pref, 'preferences_livestream');
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');

View File

@ -14,11 +14,85 @@ class Application_Model_Scheduler {
);
private $nowDT;
private $user;
public function __construct($id = null) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->nowDT = new DateTime("now", new DateTimeZone("UTC"));
$this->user = Application_Model_User::GetCurrentUser();
}
/*
* make sure any incoming requests for scheduling are ligit.
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function validateRequest($items) {
$nowEpoch = intval($this->nowDT->format("U"));
for ($i = 0; $i < count($items); $i++) {
$id = $items[$i]["id"];
//could be added to the beginning of a show, which sends id = 0;
if ($id > 0) {
$schedInfo[$id] = $items[$i]["instance"];
}
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
}
if (count($instanceInfo) === 0) {
throw new Exception("Invalid Request.");
}
$schedIds = array_keys($schedInfo);
$schedItems = CcScheduleQuery::create()->findPKs($schedIds, $this->con);
$instanceIds = array_keys($instanceInfo);
$showInstances = CcShowInstancesQuery::create()->findPKs($instanceIds, $this->con);
//an item has been deleted
if (count($schedIds) !== count($schedItems)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)");
}
//a show has been deleted
if (count($instanceIds) !== count($showInstances)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)");
}
foreach ($schedItems as $schedItem) {
$id = $schedItem->getDbId();
$instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedInfo[$id]["instance"]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
}
foreach ($showInstances as $instance) {
$id = $instance->getDbId();
$show = $instance->getCcShow($this->con);
if ($this->user->canSchedule($show->getDbId()) === false) {
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
}
$showEndEpoch = intval($instance->getDbEnds("U"));
if ($showEndEpoch < $nowEpoch) {
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
}
$origTs = intval($instanceInfo[$id]);
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($origTs !== $currTs) {
Logging::log("orig {$origTs} current {$currTs}");
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
}
}
/*
@ -117,19 +191,12 @@ class Application_Model_Scheduler {
$sEpoch = intval($DT->format("U"));
$nowEpoch = intval($this->nowDT->format("U"));
$showEndEpoch = intval($instance->getDbEnds("U"));
if ($showEndEpoch < $nowEpoch) {
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
}
//check for if the show has started.
if ($nowEpoch > $sEpoch) {
//need some kind of placeholder for cc_schedule.
//playout_status will be -1.
$nextDT = $nowDT;
$nextDT = $this->nowDT;
$length = $nowEpoch - $sEpoch;
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
@ -137,7 +204,7 @@ class Application_Model_Scheduler {
//fillers are for only storing a chunk of time space that has already passed.
$filler = new CcSchedule();
$filler->setDbStarts($DT)
->setDbEnds($nowDT)
->setDbEnds($this->nowDT)
->setDbClipLength($cliplength)
->setDbPlayoutStatus(-1)
->setDbInstanceId($instance->getDbId())
@ -171,45 +238,27 @@ class Application_Model_Scheduler {
foreach ($scheduleItems as $schedule) {
$id = intval($schedule["id"]);
$ts = intval($schedule["timestamp"]);
Logging::log("scheduling after scheduled item: ".$id);
Logging::log("in show: ".intval($schedule["instance"]));
if ($id !== 0) {
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
if (is_null($schedItem)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedule["instance"]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$schedItemEndDT = $schedItem->getDbEnds(null);
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
}
//selected empty row to add after
else {
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
//check to see if the show has started.
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
$showStartDT = $instance->getDbStarts(null);
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
}
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
//user has an old copy of the time line opened.
if ($ts !== $currTs) {
Logging::log("currTs {$currTs}, ts {$ts}");
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
$affectedShowInstances[] = $instance->getDbId();
}
Logging::log("finding items >= {$nextStartDT->format("Y-m-d H:i:s.u")}");
if ($adjustSched === true) {
$followingSchedItems = CcScheduleQuery::create()
->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
@ -217,16 +266,10 @@ class Application_Model_Scheduler {
->filterByDbId($excludeIds, Criteria::NOT_IN)
->orderByDbStarts()
->find($this->con);
foreach ($excludeIds as $id) {
Logging::log("Excluding id {$id}");
}
}
foreach($schedFiles as $file) {
Logging::log("adding file with id: ".$file["id"]);
$endTimeDT = self::findEndTime($nextStartDT, $file['cliplength']);
//item existed previously and is being moved.
@ -237,10 +280,7 @@ class Application_Model_Scheduler {
else {
$sched = new CcSchedule();
}
Logging::log("id {$sched->getDbId()}");
Logging::log("start time {$nextStartDT->format("Y-m-d H:i:s.u")}");
Logging::log("end time {$endTimeDT->format("Y-m-d H:i:s.u")}");
$sched->setDbStarts($nextStartDT);
$sched->setDbEnds($endTimeDT);
$sched->setDbFileId($file['id']);
@ -258,9 +298,7 @@ class Application_Model_Scheduler {
if ($adjustSched === true) {
//recalculate the start/end times after the inserted items.
foreach($followingSchedItems as $item) {
Logging::log("adjusting iterm {$item->getDbId()}");
foreach ($followingSchedItems as $item) {
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
@ -304,11 +342,10 @@ class Application_Model_Scheduler {
$schedFiles = array();
try {
$this->validateRequest($scheduleItems);
foreach ($mediaItems as $media) {
Logging::log("Media Id ".$media["id"]);
Logging::log("Type ".$media["type"]);
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
}
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched);
@ -333,27 +370,11 @@ class Application_Model_Scheduler {
try {
//checks on whether the item to move after is ok.
Logging::log("Moving after item: {$afterItems[0]["id"]}");
$origAfterTs = intval($afterItems[0]["timestamp"]);
if (intval($afterItems[0]["id"]) === 0) {
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
}
else {
$after = CcScheduleQuery::create()->findPk($afterItems[0]["id"], $this->con);
if (is_null($after)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$afterInstance = $after->getCcShowInstances($this->con);
}
$currTs = intval($afterInstance->getDbLastScheduled("U")) ? : 0;
if ($origAfterTs !== $currTs) {
$show = $afterInstance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
$this->validateRequest($selectedItems);
$this->validateRequest($afterItems);
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
//map show instances to cc_schedule primary keys.
$modifiedMap = array();
$movedData = array();
@ -361,24 +382,8 @@ class Application_Model_Scheduler {
//prepare each of the selected items.
for ($i = 0; $i < count($selectedItems); $i++) {
Logging::log("Moving item {$selectedItems[$i]["id"]}");
$origSelTs = intval($selectedItems[$i]["timestamp"]);
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
if (is_null($selected)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$selectedInstance = $selected->getCcShowInstances($this->con);
if (is_null($selectedInstance) || is_null($afterInstance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$currTs = intval($selectedInstance->getDbLastScheduled("U")) ? : 0;
if ($origSelTs !== $currTs) {
$show = $selectedInstance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
$data = $this->fileInfo;
$data["id"] = $selected->getDbFileId();
@ -424,29 +429,20 @@ class Application_Model_Scheduler {
$this->con->beginTransaction();
try {
$this->validateRequest($scheduledItems);
$scheduledIds = array();
foreach ($scheduledItems as $item) {
$scheduledIds[$item["id"]] = intval($item["timestamp"]);
$scheduledIds[] = $item["id"];
}
$removedItems = CcScheduleQuery::create()->findPks(array_keys($scheduledIds));
$removedItems = CcScheduleQuery::create()->findPks($scheduledIds);
//check to see if the current item is being deleted so we can truncate the record.
$currentItem = null;
//check to make sure all items selected are up to date
foreach ($removedItems as $removedItem) {
$ts = $scheduledIds[$removedItem->getDbId()];
$instance = $removedItem->getCcShowInstances($this->con);
if (is_null($instance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($ts !== $currTs) {
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
//check to truncate the currently playing item instead of deleting it.
if ($removedItem->isCurrentItem()) {

View File

@ -1481,7 +1481,7 @@ class Application_Model_Show {
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
color, background_color, file_id, cc_show_instances.id AS instance_id,
last_scheduled, time_filled
created, last_scheduled, time_filled
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
WHERE cc_show_instances.modified_instance = FALSE";

View File

@ -275,12 +275,15 @@ class Application_Model_ShowBuilder {
if (isset($show["last_scheduled"])) {
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
//check if any of the shows have a more recent timestamp.
if ($timestamp < intval($dt->format("U"))) {
$outdated = true;
break;
}
}
else {
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
}
//check if any of the shows have a more recent timestamp.
if ($timestamp < intval($dt->format("U"))) {
$outdated = true;
break;
}
}

View File

@ -140,5 +140,11 @@ class CcShowInstances extends BaseCcShowInstances {
->update(array('DbPlayoutStatus' => 0), $con);
}
public function preInsert(PropelPDO $con = null) {
$now = new DateTime("now", new DateTimeZone("UTC"));
$this->setDbCreated($now);
return true;
}
} // CcShowInstances

View File

@ -47,6 +47,7 @@ class CcShowInstancesTableMap extends TableMap {
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
$this->addColumn('TIME_FILLED', 'DbTimeFilled', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('CREATED', 'DbCreated', 'TIMESTAMP', true, null, null);
$this->addColumn('LAST_SCHEDULED', 'DbLastScheduled', 'TIMESTAMP', false, null, null);
$this->addColumn('MODIFIED_INSTANCE', 'DbModifiedInstance', 'BOOLEAN', true, null, false);
// validators

View File

@ -726,9 +726,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
if ($v !== null) {
$v = (int) $v;
}
Logging::log('$v status is '.$v);
if ($this->playout_status !== $v || $this->isNew()) {
$this->playout_status = $v;
$this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS;

View File

@ -81,6 +81,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/
protected $time_filled;
/**
* The value for the created field.
* @var string
*/
protected $created;
/**
* The value for the last_scheduled field.
* @var string
@ -293,6 +299,39 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->time_filled;
}
/**
* Get the [optionally formatted] temporal [created] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbCreated($format = 'Y-m-d H:i:s')
{
if ($this->created === null) {
return null;
}
try {
$dt = new DateTime($this->created);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [optionally formatted] temporal [last_scheduled] column value.
*
@ -586,6 +625,55 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this;
} // setDbTimeFilled()
/**
* Sets the value of [created] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcShowInstances The current object (for fluent API support)
*/
public function setDbCreated($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->created !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->created = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcShowInstancesPeer::CREATED;
}
} // if either are not null
return $this;
} // setDbCreated()
/**
* Sets the value of [last_scheduled] column to a normalized version of the date/time value specified.
*
@ -712,8 +800,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->last_scheduled = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->modified_instance = ($row[$startcol + 10] !== null) ? (boolean) $row[$startcol + 10] : null;
$this->created = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->last_scheduled = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
$this->modified_instance = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null;
$this->resetModified();
$this->setNew(false);
@ -722,7 +811,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 11; // 11 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 12; // 12 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowInstances object", $e);
@ -1147,9 +1236,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->getDbTimeFilled();
break;
case 9:
return $this->getDbLastScheduled();
return $this->getDbCreated();
break;
case 10:
return $this->getDbLastScheduled();
break;
case 11:
return $this->getDbModifiedInstance();
break;
default:
@ -1185,8 +1277,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$keys[6] => $this->getDbOriginalShow(),
$keys[7] => $this->getDbRecordedFile(),
$keys[8] => $this->getDbTimeFilled(),
$keys[9] => $this->getDbLastScheduled(),
$keys[10] => $this->getDbModifiedInstance(),
$keys[9] => $this->getDbCreated(),
$keys[10] => $this->getDbLastScheduled(),
$keys[11] => $this->getDbModifiedInstance(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -1257,9 +1350,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->setDbTimeFilled($value);
break;
case 9:
$this->setDbLastScheduled($value);
$this->setDbCreated($value);
break;
case 10:
$this->setDbLastScheduled($value);
break;
case 11:
$this->setDbModifiedInstance($value);
break;
} // switch()
@ -1295,8 +1391,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbLastScheduled($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setDbModifiedInstance($arr[$keys[10]]);
if (array_key_exists($keys[9], $arr)) $this->setDbCreated($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setDbLastScheduled($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setDbModifiedInstance($arr[$keys[11]]);
}
/**
@ -1317,6 +1414,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled);
if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created);
if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled);
if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance);
@ -1388,6 +1486,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$copyObj->setDbOriginalShow($this->instance_id);
$copyObj->setDbRecordedFile($this->file_id);
$copyObj->setDbTimeFilled($this->time_filled);
$copyObj->setDbCreated($this->created);
$copyObj->setDbLastScheduled($this->last_scheduled);
$copyObj->setDbModifiedInstance($this->modified_instance);
@ -1907,6 +2006,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = null;
$this->file_id = null;
$this->time_filled = null;
$this->created = null;
$this->last_scheduled = null;
$this->modified_instance = null;
$this->alreadyInSave = false;

View File

@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer {
const TM_CLASS = 'CcShowInstancesTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 11;
const NUM_COLUMNS = 12;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -58,6 +58,9 @@ abstract class BaseCcShowInstancesPeer {
/** the column name for the TIME_FILLED field */
const TIME_FILLED = 'cc_show_instances.TIME_FILLED';
/** the column name for the CREATED field */
const CREATED = 'cc_show_instances.CREATED';
/** the column name for the LAST_SCHEDULED field */
const LAST_SCHEDULED = 'cc_show_instances.LAST_SCHEDULED';
@ -80,12 +83,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbLastScheduled', 'DbModifiedInstance', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbLastScheduled', 'dbModifiedInstance', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'last_scheduled', 'modified_instance', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::CREATED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
/**
@ -95,12 +98,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbLastScheduled' => 9, 'DbModifiedInstance' => 10, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbLastScheduled' => 9, 'dbModifiedInstance' => 10, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::LAST_SCHEDULED => 9, self::MODIFIED_INSTANCE => 10, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'LAST_SCHEDULED' => 9, 'MODIFIED_INSTANCE' => 10, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'last_scheduled' => 9, 'modified_instance' => 10, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbCreated' => 9, 'DbLastScheduled' => 10, 'DbModifiedInstance' => 11, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbCreated' => 9, 'dbLastScheduled' => 10, 'dbModifiedInstance' => 11, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::CREATED => 9, self::LAST_SCHEDULED => 10, self::MODIFIED_INSTANCE => 11, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'CREATED' => 9, 'LAST_SCHEDULED' => 10, 'MODIFIED_INSTANCE' => 11, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'created' => 9, 'last_scheduled' => 10, 'modified_instance' => 11, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
/**
@ -181,6 +184,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED);
$criteria->addSelectColumn(CcShowInstancesPeer::CREATED);
$criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED);
$criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE);
} else {
@ -193,6 +197,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
$criteria->addSelectColumn($alias . '.FILE_ID');
$criteria->addSelectColumn($alias . '.TIME_FILLED');
$criteria->addSelectColumn($alias . '.CREATED');
$criteria->addSelectColumn($alias . '.LAST_SCHEDULED');
$criteria->addSelectColumn($alias . '.MODIFIED_INSTANCE');
}

View File

@ -15,6 +15,7 @@
* @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column
* @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column
* @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column
* @method CcShowInstancesQuery orderByDbCreated($order = Criteria::ASC) Order by the created column
* @method CcShowInstancesQuery orderByDbLastScheduled($order = Criteria::ASC) Order by the last_scheduled column
* @method CcShowInstancesQuery orderByDbModifiedInstance($order = Criteria::ASC) Order by the modified_instance column
*
@ -27,6 +28,7 @@
* @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column
* @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column
* @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column
* @method CcShowInstancesQuery groupByDbCreated() Group by the created column
* @method CcShowInstancesQuery groupByDbLastScheduled() Group by the last_scheduled column
* @method CcShowInstancesQuery groupByDbModifiedInstance() Group by the modified_instance column
*
@ -66,6 +68,7 @@
* @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column
* @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column
* @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column
* @method CcShowInstances findOneByDbCreated(string $created) Return the first CcShowInstances filtered by the created column
* @method CcShowInstances findOneByDbLastScheduled(string $last_scheduled) Return the first CcShowInstances filtered by the last_scheduled column
* @method CcShowInstances findOneByDbModifiedInstance(boolean $modified_instance) Return the first CcShowInstances filtered by the modified_instance column
*
@ -78,6 +81,7 @@
* @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column
* @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column
* @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column
* @method array findByDbCreated(string $created) Return CcShowInstances objects filtered by the created column
* @method array findByDbLastScheduled(string $last_scheduled) Return CcShowInstances objects filtered by the last_scheduled column
* @method array findByDbModifiedInstance(boolean $modified_instance) Return CcShowInstances objects filtered by the modified_instance column
*
@ -445,6 +449,37 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison);
}
/**
* Filter the query on the created column
*
* @param string|array $dbCreated The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbCreated($dbCreated = null, $comparison = null)
{
if (is_array($dbCreated)) {
$useMinMax = false;
if (isset($dbCreated['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbCreated['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated, $comparison);
}
/**
* Filter the query on the last_scheduled column
*

View File

@ -161,6 +161,7 @@
<column name="instance_id" phpName="DbOriginalShow" type="INTEGER" required="false"/>
<column name="file_id" phpName="DbRecordedFile" type="INTEGER" required="false"/>
<column name="time_filled" phpName="DbTimeFilled" type="VARCHAR" sqlType="interval" defaultValue="00:00:00" />
<column name="created" phpName="DbCreated" type="TIMESTAMP" required="true"/>
<column name="last_scheduled" phpName="DbLastScheduled" type="TIMESTAMP" required="false"/>
<!-- The purpose of the modified_instance column is to mark a show instance that was
deleted when it was part of repeating show. This is useful because the way shows work,

View File

@ -207,6 +207,7 @@ CREATE TABLE "cc_show_instances"
"instance_id" INTEGER,
"file_id" INTEGER,
"time_filled" interval default '00:00:00',
"created" TIMESTAMP NOT NULL,
"last_scheduled" TIMESTAMP,
"modified_instance" BOOLEAN default 'f' NOT NULL,
PRIMARY KEY ("id")