/** * Filter the query by a related CcWebstreamMetadata object * * @param CcWebstreamMetadata $ccWebstreamMetadata the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return CcScheduleQuery The current query, for fluid interface */ public function filterByCcWebstreamMetadata($ccWebstreamMetadata, $comparison = null) { return $this->addUsingAlias(CcSchedulePeer::ID, $ccWebstreamMetadata->getDbInstanceId(), $comparison); }
public function notifyWebstreamDataAction() { $request = $this->getRequest(); $data = $request->getParam("data"); $media_id = intval($request->getParam("media_id")); $data_arr = json_decode($data); //$media_id is -1 sometimes when a stream has stopped playing if (!is_null($media_id) && $media_id > 0) { if (isset($data_arr->title)) { $data_title = substr($data_arr->title, 0, 1024); $previous_metadata = CcWebstreamMetadataQuery::create()->orderByDbStartTime('desc')->filterByDbInstanceId($media_id)->findOne(); $do_insert = true; if ($previous_metadata) { if ($previous_metadata->getDbLiquidsoapData() == $data_title) { Logging::debug("Duplicate found: " . $data_title); $do_insert = false; } } if ($do_insert) { $startDT = new DateTime("now", new DateTimeZone("UTC")); $webstream_metadata = new CcWebstreamMetadata(); $webstream_metadata->setDbInstanceId($media_id); $webstream_metadata->setDbStartTime($startDT); $webstream_metadata->setDbLiquidsoapData($data_title); $webstream_metadata->save(); $historyService = new Application_Service_HistoryService(); $historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr); } } } $this->view->response = $data; $this->view->media_id = $media_id; }
public function notifyWebstreamDataAction() { $request = $this->getRequest(); $data = $request->getParam("data"); $media_id = $request->getParam("media_id"); $data_arr = json_decode($data); if (!is_null($media_id) && isset($data_arr->title) && strlen($data_arr->title) < 1024) { $previous_metadata = CcWebstreamMetadataQuery::create()->orderByDbStartTime('desc')->filterByDbInstanceId($media_id)->findOne(); $do_insert = true; if ($previous_metadata) { if ($previous_metadata->getDbLiquidsoapData() == $data_arr->title) { Logging::debug("Duplicate found: " . $data_arr->title); $do_insert = false; } } if ($do_insert) { $webstream_metadata = new CcWebstreamMetadata(); $webstream_metadata->setDbInstanceId($media_id); $webstream_metadata->setDbStartTime(new DateTime("now", new DateTimeZone("UTC"))); $webstream_metadata->setDbLiquidsoapData($data_arr->title); $webstream_metadata->save(); } } else { throw new Error("Unexpected error. media_id {$media_id} has a null stream value in cc_schedule!"); } $this->view->response = $data; $this->view->media_id = $media_id; }
/** * Exclude object from result * * @param CcWebstreamMetadata $ccWebstreamMetadata Object to remove from the list of results * * @return CcWebstreamMetadataQuery The current query, for fluid interface */ public function prune($ccWebstreamMetadata = null) { if ($ccWebstreamMetadata) { $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $ccWebstreamMetadata->getDbId(), Criteria::NOT_EQUAL); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param CcWebstreamMetadata $value A CcWebstreamMetadata object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(CcWebstreamMetadata $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getDbId(); } // if key === null self::$instances[$key] = $obj; } }