CC-3884 : UI constantly refreshes when filtered by a show in a timerange
This commit is contained in:
parent
1b115178d3
commit
8b4c876c5b
1 changed files with 45 additions and 20 deletions
|
@ -60,6 +60,22 @@ class Application_Model_ShowBuilder {
|
||||||
$this->currentShow = false;
|
$this->currentShow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getUsersShows() {
|
||||||
|
|
||||||
|
$shows = array();
|
||||||
|
|
||||||
|
$host_shows = CcShowHostsQuery::create()
|
||||||
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||||
|
->filterByDbHost($this->user->getId())
|
||||||
|
->find();
|
||||||
|
|
||||||
|
foreach ($host_shows as $host_show) {
|
||||||
|
$shows[] = $host_show->getDbShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $shows;
|
||||||
|
}
|
||||||
|
|
||||||
//check to see if this row should be editable by the user.
|
//check to see if this row should be editable by the user.
|
||||||
private function isAllowed($p_item, &$row) {
|
private function isAllowed($p_item, &$row) {
|
||||||
|
|
||||||
|
@ -333,27 +349,43 @@ class Application_Model_ShowBuilder {
|
||||||
public function hasBeenUpdatedSince($timestamp, $instances) {
|
public function hasBeenUpdatedSince($timestamp, $instances) {
|
||||||
$outdated = false;
|
$outdated = false;
|
||||||
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
||||||
|
|
||||||
|
if ($this->opts["showFilter"] !== 0) {
|
||||||
|
$include[] = $this->opts["showFilter"];
|
||||||
|
}
|
||||||
|
else if ($this->opts["myShows"] === 1) {
|
||||||
|
|
||||||
|
$include = $this->getUsersShows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$currentInstances = array();
|
$currentInstances = array();
|
||||||
|
|
||||||
foreach ($shows as $show) {
|
foreach ($shows as $show) {
|
||||||
$currentInstances[] = $show["instance_id"];
|
|
||||||
|
|
||||||
if (isset($show["last_scheduled"])) {
|
if (empty($include) || in_array($show["show_id"], $include)) {
|
||||||
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
|
$currentInstances[] = $show["instance_id"];
|
||||||
}
|
|
||||||
else {
|
|
||||||
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if any of the shows have a more recent timestamp.
|
if (isset($show["last_scheduled"])) {
|
||||||
if ($timestamp < intval($dt->format("U"))) {
|
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
|
||||||
$outdated = true;
|
}
|
||||||
break;
|
else {
|
||||||
|
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if any of the shows have a more recent timestamp.
|
||||||
|
$showTimeStamp = intval($dt->format("U"));
|
||||||
|
if ($timestamp < $showTimeStamp) {
|
||||||
|
Logging::debug("timestamp is {$timestamp} show timestamp is {$showTimeStamp}");
|
||||||
|
$outdated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//see if the displayed show instances have changed. (deleted, empty schedule etc)
|
//see if the displayed show instances have changed. (deleted, empty schedule etc)
|
||||||
if ($outdated === false && count($instances) !== count($currentInstances)) {
|
if ($outdated === false && count($instances) !== count($currentInstances)) {
|
||||||
|
Logging::debug("show instances have changed.");
|
||||||
$outdated = true;
|
$outdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,14 +400,7 @@ class Application_Model_ShowBuilder {
|
||||||
$shows = array();
|
$shows = array();
|
||||||
if ($this->opts["myShows"] === 1) {
|
if ($this->opts["myShows"] === 1) {
|
||||||
|
|
||||||
$host_shows = CcShowHostsQuery::create()
|
$shows = $this->getUsersShows();
|
||||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
|
||||||
->filterByDbHost($this->user->getId())
|
|
||||||
->find();
|
|
||||||
|
|
||||||
foreach ($host_shows as $host_show) {
|
|
||||||
$shows[] = $host_show->getDbShow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ($this->opts["showFilter"] !== 0) {
|
else if ($this->opts["showFilter"] !== 0) {
|
||||||
$shows[] = $this->opts["showFilter"];
|
$shows[] = $this->opts["showFilter"];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue