CC-5396 : Playout History: Restart airtime-liquidsoap will cause redundant items in history log
This commit is contained in:
parent
916d85ca57
commit
61bab553ff
|
@ -575,26 +575,38 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
$instanceEnd = $showInstance->getDbEnds(null);
|
$instanceEnd = $showInstance->getDbEnds(null);
|
||||||
$itemEnd = $item->getDbEnds(null);
|
$itemEnd = $item->getDbEnds(null);
|
||||||
|
$recordStart = $item->getDbStarts(null);
|
||||||
$recordEnd = ($instanceEnd < $itemEnd) ? $instanceEnd : $itemEnd;
|
$recordEnd = ($instanceEnd < $itemEnd) ? $instanceEnd : $itemEnd;
|
||||||
|
|
||||||
$history = new CcPlayoutHistory();
|
//first check if this is a duplicate
|
||||||
$history->setDbFileId($fileId);
|
// (caused by restarting liquidsoap)
|
||||||
$history->setDbStarts($item->getDbStarts(null));
|
|
||||||
$history->setDbEnds($recordEnd);
|
$prevRecord = CcPlayoutHistoryQuery::create()
|
||||||
$history->setDbInstanceId($item->getDbInstanceId());
|
->filterByDbStarts($recordStart)
|
||||||
|
->filterByDbEnds($recordEnd)
|
||||||
foreach ($metadata as $key => $val) {
|
->filterByDbFileId($fileId)
|
||||||
$meta = new CcPlayoutHistoryMetaData();
|
->findOne($this->con);
|
||||||
$meta->setDbKey($key);
|
|
||||||
$meta->setDbValue($val);
|
if (empty($prevRecord)) {
|
||||||
|
|
||||||
$history->addCcPlayoutHistoryMetaData($meta);
|
$history = new CcPlayoutHistory();
|
||||||
}
|
$history->setDbFileId($fileId);
|
||||||
|
$history->setDbStarts($recordStart);
|
||||||
$history->save($this->con);
|
$history->setDbEnds($recordEnd);
|
||||||
}
|
$history->setDbInstanceId($item->getDbInstanceId());
|
||||||
|
|
||||||
$this->con->commit();
|
foreach ($metadata as $key => $val) {
|
||||||
|
$meta = new CcPlayoutHistoryMetaData();
|
||||||
|
$meta->setDbKey($key);
|
||||||
|
$meta->setDbValue($val);
|
||||||
|
|
||||||
|
$history->addCcPlayoutHistoryMetaData($meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
$history->save($this->con);
|
||||||
|
$this->con->commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$this->con->rollback();
|
$this->con->rollback();
|
||||||
|
|
Loading…
Reference in New Issue