clean up shows endpoint, remove dependency on Show model

This commit is contained in:
Mark Lewis 2014-11-20 18:16:52 +01:00 committed by Albert Santoni
parent a27ca2f583
commit 174cf79d84
3 changed files with 22 additions and 30 deletions

View File

@ -1394,13 +1394,12 @@ class ApiController extends Zend_Controller_Action
$results = array();
if (empty($showId)) {
$shows = Application_Model_Show::getDistinctShows();
foreach($shows as $baseShow) {
$show = new Application_Model_Show($baseShow->getDbId());
$shows = CcShowQuery::create()->find();
foreach($shows as $show) {
$results[] = $show->getShowInfo();
}
} else {
$show = new Application_Model_Show($showId);
$show = CcShowQuery::create()->findPK($showId);
$results[] = $show->getShowInfo();
}

View File

@ -786,28 +786,6 @@ SQL;
}
}
/**
* returns show specific info (not related to isntance)
*/
public function getShowInfo()
{
$info = array();
if ($this->getId() == null) {
return $info;
} else {
$ccShow = CcShowQuery::create()->findPK($this->_showId);
$info['name'] = $ccShow->getDbName();
$info['id'] = $ccShow->getDbId();
$info['url'] = $ccShow->getDbUrl();
$info['genre'] = $ccShow->getDbGenre();
$info['description'] = $ccShow->getDbDescription();
$info['color'] = $ccShow->getDbColor();
$info['background_color'] = $ccShow->getDbBackgroundColor();
$info['linked'] = $ccShow->getDbLinked();
return $info;
}
}
/* Only used for shows that are repeating. Note that this will return
* true even for dates that only have a "modified" show instance (does not
* check if the "modified_instance" column is set to true). This is intended
@ -1482,8 +1460,4 @@ SQL;
return array($start, $end);
}
public static function getDistinctShows() {
$shows = CcShowQuery::create()->find();
return $shows;
}
}

View File

@ -304,4 +304,23 @@ class CcShow extends BaseCcShow {
->filterByDbId($instanceId, Criteria::NOT_EQUAL)
->find();
}
public function getShowInfo()
{
$info = array();
if ($this->getDbId() == null) {
return $info;
} else {
$info['name'] = $this->getDbName();
$info['id'] = $this->getDbId();
$info['url'] = $this->getDbUrl();
$info['genre'] = $this->getDbGenre();
$info['description'] = $this->getDbDescription();
$info['color'] = $this->getDbColor();
$info['background_color'] = $this->getDbBackgroundColor();
$info['linked'] = $this->getDbLinked();
return $info;
}
}
} // CcShow