Commit 9bed8390 by Phạm Văn Đoan

test lấy số liệu lịch sử lượt nghe từ views listen_history_view

parent ce500d2d
...@@ -312,6 +312,25 @@ class CmsRanking extends CI_Controller ...@@ -312,6 +312,25 @@ class CmsRanking extends CI_Controller
} }
} }
/*$histories_view = $this->crawler_listen_history_model->getByTrackIdFromView($track_id);
$date_list = $histories_view[0]['date_log_list'];
$zing_list = $histories_view[0]['zing_count_list'];
$nct_list = $histories_view[0]['nct_count_list'];
$keeng_list = $histories_view[0]['keeng_count_list'];
//
$array_date = explode(',', $date_list);
$array_zing = explode(',', $zing_list);
$array_nct = explode(',', $nct_list);
$array_keeng = explode(',', $keeng_list);
//
$data = [];
foreach ($array_date as $key => $val) {
$data[$key]['date'] = $val;
$data[$key]['zing'] = intval($array_zing[$key]);
$data[$key]['nct'] = intval($array_nct[$key]);
$data[$key]['keeng'] = intval($array_keeng[$key]);
}*/
$response['response'] = $data; $response['response'] = $data;
$response['track_title'] = $track_title; $response['track_title'] = $track_title;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class Crawler_listen_history_model extends CI_Model class Crawler_listen_history_model extends CI_Model
{ {
protected $_table = 'crawler_listen_histories'; protected $_table = 'crawler_listen_histories';
protected $_table_view = 'listen_history_view';
public function __construct() public function __construct()
{ {
...@@ -23,6 +24,23 @@ class Crawler_listen_history_model extends CI_Model ...@@ -23,6 +24,23 @@ class Crawler_listen_history_model extends CI_Model
$this->db->where($this->_table . '.track_id', $track_id); $this->db->where($this->_table . '.track_id', $track_id);
$this->db->order_by($this->_table . '.date_log', 'asc'); $this->db->order_by($this->_table . '.date_log', 'asc');
$query = $this->db->get(); $query = $this->db->get();
return $query->result_array();
}
/**
* Lấy lịch sử lượt nghe của bài hát theo ID từ views
*
* @param $track_id
* @return mixed
*/
public function getByTrackIdFromView($track_id)
{
$this->db->select($this->_table_view . '.*');
$this->db->from($this->_table_view);
$this->db->where($this->_table_view . '.track_id', $track_id);
$query = $this->db->get();
return $query->result_array(); return $query->result_array();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment