diff --git a/application/modules/default/models/DbTable/MediaViews.php b/application/modules/default/models/DbTable/MediaViews.php index fe2494e87..3b2ad4c62 100755 --- a/application/modules/default/models/DbTable/MediaViews.php +++ b/application/modules/default/models/DbTable/MediaViews.php @@ -1,123 +1,123 @@ . **/ class Default_Model_DbTable_MediaViews extends Local_Model_Table { /** @var Zend_Cache_Core */ protected $cache; protected $_name = "media_views"; protected $_keyColumnsForRow = array('media_view_id'); protected $_key = 'media_view_id'; const MEDIA_TYPE_VIDEO = 1; const MEDIA_TYPE_MUSIC = 2; const MEDIA_TYPE_BOOK = 3; public function getNewId() { $result = $this->getAdapter()->query('SELECT UUID_SHORT()')->fetch(); return $result['UUID_SHORT()']; } /** * @inheritDoc */ public function init() { parent::init(); // TODO: Change the autogenerated stub $this->cache = Zend_Registry::get('cache'); } public function fetchCountViewsTodayForFile($collection_id, $file_id) { if(empty($collection_id)) { return 0; } $today = (new DateTime())->modify('-1 day'); $filterDownloadToday = $today->format("Y-m-d H:i:s"); $sql = " SELECT COUNT(1) AS cnt FROM media_views f WHERE f.collection_id = " . $collection_id . " AND f.file_id = " . $file_id . " AND f.start_timestamp >= '" . $filterDownloadToday . "' "; $result = $this->_db->query($sql)->fetchAll(); return $result[0]['cnt']; } public function fetchCountViewsForFileAllTime($collectionId, $file_id) { if(empty($file_id) || empty($collectionId)) { return 0; } $sql = " SELECT COUNT(1) AS cnt FROM media_views f WHERE f.collection_id = " . $collectionId . " AND f.file_id = " . $file_id . " "; $result = $this->_db->query($sql)->fetchAll(); return $result[0]['cnt']; } public function fetchCountViewsTodayForProject($project_id) { if(empty($project_id)) { return 0; } $today = (new DateTime())->modify('-1 day'); $filterDownloadToday = $today->format("Y-m-d H:i:s"); $sql = " SELECT COUNT(1) AS cnt FROM media_views f WHERE f.project_id = " . $project_id . " AND f.start_timestamp >= '" . $filterDownloadToday . "' "; $result = $this->_db->query($sql)->fetchAll(); return $result[0]['cnt']; } public function fetchCountViewsForProjectAllTime($project_id) { - if(empty($$project_id)) { + if(empty($project_id)) { return 0; } $sql = " SELECT COUNT(1) AS cnt FROM media_views f WHERE f.project_id = " . $project_id . " "; $result = $this->_db->query($sql)->fetchAll(); return $result[0]['cnt']; } } \ No newline at end of file