Commit 0ab190d7 by Phạm Văn Đoan

Cập nhật tính năng bỏ bài khỏi BXH sau 6 tháng

parent 060f73de
...@@ -45,6 +45,7 @@ class CmsTrack extends CI_Controller ...@@ -45,6 +45,7 @@ class CmsTrack extends CI_Controller
$fBySinger = $this->input->post('fBySinger'); $fBySinger = $this->input->post('fBySinger');
$fByComposer = $this->input->post('fByComposer'); $fByComposer = $this->input->post('fByComposer');
$fByBlacklist = $this->input->post('fByBlacklist'); $fByBlacklist = $this->input->post('fByBlacklist');
$fByRemoveRanking = $this->input->post('fByRemoveRanking');
$pageId = $this->input->post('pageId'); $pageId = $this->input->post('pageId');
// //
$pageId = ($pageId == 0) ? 1 : $pageId; $pageId = ($pageId == 0) ? 1 : $pageId;
...@@ -52,9 +53,9 @@ class CmsTrack extends CI_Controller ...@@ -52,9 +53,9 @@ class CmsTrack extends CI_Controller
$limit = 100; $limit = 100;
$offset = ($pageId - 1) * $limit; $offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit; $data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist); $totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist, $fByRemoveRanking);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId); $data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist); $data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist, $fByRemoveRanking);
// //
$this->load->view('backend/ajax/cms_track/list_track_view', $data); $this->load->view('backend/ajax/cms_track/list_track_view', $data);
} }
...@@ -576,7 +577,8 @@ class CmsTrack extends CI_Controller ...@@ -576,7 +577,8 @@ class CmsTrack extends CI_Controller
$reset = $this->crawler_listen_model->resetCrawlerListenBySrc($track_id, $src); $reset = $this->crawler_listen_model->resetCrawlerListenBySrc($track_id, $src);
// Reset data ở bảng crawler_listen_histories // Reset data ở bảng crawler_listen_histories
if ($reset) { // Không reset với trường hợp quá 6 tháng
if ($reset && $src != 'all_6months') {
$this->crawler_listen_history_model->resetCrawlerListenHistoryBySrc($track_id, $src); $this->crawler_listen_history_model->resetCrawlerListenHistoryBySrc($track_id, $src);
} }
} }
......
...@@ -67,6 +67,7 @@ class Crawler_listen_blacklist_model extends CI_Model ...@@ -67,6 +67,7 @@ class Crawler_listen_blacklist_model extends CI_Model
'track_id' => $track_id, 'track_id' => $track_id,
'src' => strtolower($src), 'src' => strtolower($src),
'title' => $title, 'title' => $title,
'created_by' => $this->session->userdata('id'),
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s') 'updated_at' => date('Y-m-d H:i:s')
]); ]);
......
...@@ -13,6 +13,7 @@ class Crawler_listen_model extends CI_Model ...@@ -13,6 +13,7 @@ class Crawler_listen_model extends CI_Model
/** /**
* Hàm thực hiện reset lượt nghe ở nguồn tương ứng * Hàm thực hiện reset lượt nghe ở nguồn tương ứng
* khi user tích chọn không lấy lượt nghe ở nguồn src nào đó * khi user tích chọn không lấy lượt nghe ở nguồn src nào đó
* Cập nhật thêm case: sau 6 tháng sẽ loại bỏ bài hát khỏi BXH (18/10/2020)
* *
* @param $track_id * @param $track_id
* @param $src * @param $src
...@@ -65,6 +66,34 @@ class Crawler_listen_model extends CI_Model ...@@ -65,6 +66,34 @@ class Crawler_listen_model extends CI_Model
'keeng_crawler_at' => null 'keeng_crawler_at' => null
]; ];
break; break;
case 'all_6months':
$data_reset = [
'yesterday_zing' => 0,
'today_zing' => 0,
'date_zing' => 0,
'week_zing' => 0,
'month_zing' => 0,
'year_zing' => 0,
'alltime_zing' => 0,
'zing_crawler_at' => null,
'yesterday_nct' => 0,
'today_nct' => 0,
'date_nct' => 0,
'week_nct' => 0,
'month_nct' => 0,
'year_nct' => 0,
'alltime_nct' => 0,
'nct_crawler_at' => null,
'yesterday_keeng' => 0,
'today_keeng' => 0,
'date_keeng' => 0,
'week_keeng' => 0,
'month_keeng' => 0,
'year_keeng' => 0,
'alltime_keeng' => 0,
'keeng_crawler_at' => null
];
break;
default: default:
$data_reset = []; $data_reset = [];
} }
......
...@@ -227,7 +227,7 @@ class Track_model extends CI_Model ...@@ -227,7 +227,7 @@ class Track_model extends CI_Model
return $query->result_array(); return $query->result_array();
} }
public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = null) public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = null, $fByRemoveRanking = null)
{ {
$this->db->select('COUNT(*) AS totalResults'); $this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -268,6 +268,9 @@ class Track_model extends CI_Model ...@@ -268,6 +268,9 @@ class Track_model extends CI_Model
if ($fByBlacklist == 1) { if ($fByBlacklist == 1) {
$this->db->where('blacklist_listen is NOT NULL', null, false); $this->db->where('blacklist_listen is NOT NULL', null, false);
} }
if ($fByRemoveRanking == 1) {
$this->db->where('is_remove_from_ranking', $fByRemoveRanking);
}
$query = $this->db->get(); $query = $this->db->get();
$result = $query->result_array(); $result = $query->result_array();
if ($result) { if ($result) {
...@@ -277,7 +280,7 @@ class Track_model extends CI_Model ...@@ -277,7 +280,7 @@ class Track_model extends CI_Model
} }
} }
public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = null) public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = null, $fByRemoveRanking = null)
{ {
$this->db->select($this->_table . '.*'); $this->db->select($this->_table . '.*');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -318,6 +321,9 @@ class Track_model extends CI_Model ...@@ -318,6 +321,9 @@ class Track_model extends CI_Model
if ($fByBlacklist == 1) { if ($fByBlacklist == 1) {
$this->db->where('blacklist_listen is NOT NULL', null, false); $this->db->where('blacklist_listen is NOT NULL', null, false);
} }
if ($fByRemoveRanking == 1) {
$this->db->where('is_remove_from_ranking', $fByRemoveRanking);
}
$this->db->order_by($this->_table . '.id', 'desc'); $this->db->order_by($this->_table . '.id', 'desc');
$this->db->limit($record, $start); $this->db->limit($record, $start);
$query = $this->db->get(); $query = $this->db->get();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<th style="text-align: center">Tên bài hát</th> <th style="text-align: center">Tên bài hát</th>
<th style="text-align: center">Nghệ sĩ</th> <th style="text-align: center">Nghệ sĩ</th>
<th style="text-align: center">Trang không lấy<br>lượt nghe</th> <th style="text-align: center">Trang không lấy<br>lượt nghe</th>
<th style="text-align: center; width: 100px">BXH<br>quá 6 tháng</th>
<th style="text-align: center">Xử lý</th> <th style="text-align: center">Xử lý</th>
</tr> </tr>
</thead> </thead>
...@@ -31,6 +32,18 @@ ...@@ -31,6 +32,18 @@
</td> </td>
<td style="text-align: left"><?php echo strtoupper($data['blacklist_listen']); ?></td> <td style="text-align: left"><?php echo strtoupper($data['blacklist_listen']); ?></td>
<td style="text-align: center"> <td style="text-align: center">
<?php if($data['is_remove_from_ranking']): ?>
<input type="checkbox" disabled checked="checked">
<?php else: ?>
<?php if ($this->session->userdata('group_id') == 2): ?>
<input type="checkbox" id="chk_<?php echo $data['id']; ?>"
onclick="updateBlacklistMore6MonthsByAjax(<?php echo $data['id']?>, '<?php echo $data['title']?>', 'all_6months')">
<?php else: ?>
<span></span>
<?php endif; ?>
<?php endif; ?>
</td>
<td style="text-align: center">
<a href="<?php echo base_url('backend/cmsTrack/showTrack/'.$data['id']); ?>" title="Xem chi tiết"> <a href="<?php echo base_url('backend/cmsTrack/showTrack/'.$data['id']); ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-eye bigger-130"></i> <i class="ace-icon fa fa-eye bigger-130"></i>
</a> </a>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<?php MyHelper::loadView('backend/cms_partials/error_message_view') ?> <?php MyHelper::loadView('backend/cms_partials/error_message_view') ?>
<div class="row"> <div class="row">
<!-- Tìm kiếm theo tên bài hát --> <!-- Tìm kiếm theo tên bài hát -->
<div class="col-lg-3"> <div class="col-lg-2">
<input class="form-control" type="text" name="input-name" id="input-name" placeholder="Nhập #ID, tên bài hát..." /> <input class="form-control" type="text" name="input-name" id="input-name" placeholder="Nhập #ID, tên bài hát..." />
</div> </div>
<!-- Lọc theo nguồn cung cấp nhạc --> <!-- Lọc theo nguồn cung cấp nhạc -->
...@@ -36,10 +36,16 @@ ...@@ -36,10 +36,16 @@
<option value="1">Đã chặn</option> <option value="1">Đã chặn</option>
</select> </select>
</div> </div>
<div class="col-lg-2">
<select class="form-control" name="fByRemoveRanking" id="fByRemoveRanking">
<option value="-1">- Bỏ khỏi BXH -</option>
<option value="1">Đã bỏ BXH</option>
</select>
</div>
<!-- Xóa bộ lọc --> <!-- Xóa bộ lọc -->
<div class="col-lg-1"> <!--<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button> <button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div> </div>-->
<!-- Thêm mới bài hát --> <!-- Thêm mới bài hát -->
<!--<div class="col-lg-1" style="float:right;"> <!--<div class="col-lg-1" style="float:right;">
<a class="btn btn-sm btn-success" href="<?php /*echo base_url('backend/cmsTrack/addTrack');*/?>"> <a class="btn btn-sm btn-success" href="<?php /*echo base_url('backend/cmsTrack/addTrack');*/?>">
...@@ -74,6 +80,7 @@ $(document).ready(function() { ...@@ -74,6 +80,7 @@ $(document).ready(function() {
loadDataByAjaxFromSelectBox('fBySinger', url); loadDataByAjaxFromSelectBox('fBySinger', url);
loadDataByAjaxFromSelectBox('fByComposer', url); loadDataByAjaxFromSelectBox('fByComposer', url);
loadDataByAjaxFromSelectBox('fByBlacklist', url); loadDataByAjaxFromSelectBox('fByBlacklist', url);
loadDataByAjaxFromSelectBox('fByRemoveRanking', url);
// Xóa bộ lọc // Xóa bộ lọc
$('#delete-filter').click(function() { $('#delete-filter').click(function() {
...@@ -81,6 +88,7 @@ $(document).ready(function() { ...@@ -81,6 +88,7 @@ $(document).ready(function() {
$("#fBySinger").val('-1'); $("#fBySinger").val('-1');
$("#fByComposer").val('-1'); $("#fByComposer").val('-1');
$("#fByBlacklist").val('-1'); $("#fByBlacklist").val('-1');
$("#fByRemoveRanking").val('-1');
changePagination('0'); changePagination('0');
return false; return false;
...@@ -122,6 +130,7 @@ function callAjax(pageId, url) { ...@@ -122,6 +130,7 @@ function callAjax(pageId, url) {
var fBySinger = $("#fBySinger").val(); var fBySinger = $("#fBySinger").val();
var fByComposer = $("#fByComposer").val(); var fByComposer = $("#fByComposer").val();
var fByBlacklist = $("#fByBlacklist").val(); var fByBlacklist = $("#fByBlacklist").val();
var fByRemoveRanking = $("#fByRemoveRanking").val();
var dataReq = { var dataReq = {
csrf_name: csrf_value, csrf_name: csrf_value,
fByName: fByName, fByName: fByName,
...@@ -129,6 +138,7 @@ function callAjax(pageId, url) { ...@@ -129,6 +138,7 @@ function callAjax(pageId, url) {
fBySinger: fBySinger, fBySinger: fBySinger,
fByComposer: fByComposer, fByComposer: fByComposer,
fByBlacklist: fByBlacklist, fByBlacklist: fByBlacklist,
fByRemoveRanking: fByRemoveRanking,
pageId: pageId pageId: pageId
}; };
//Ajax //Ajax
...@@ -144,4 +154,41 @@ function callAjax(pageId, url) { ...@@ -144,4 +154,41 @@ function callAjax(pageId, url) {
} }
}); });
} }
function updateBlacklistMore6MonthsByAjax(track_id, title, src) {
$('#data-loading').show();
var selected = 0;
if ($('#chk_' + track_id).is(":checked")) {
selected = 1;
} else {
selected = 0;
}
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url("backend/cmsTrack/updateBlacklistByAjax"); ?>';
var dataReq = {
csrf_name: csrf_value,
track_id: track_id,
title: title,
src: src,
selected: selected
};
//Ajax
$.ajax({
type: "POST",
url: url,
data: dataReq,
dataType: "JSON",
cache: false,
success: function(data) {
$('#data-loading').hide();
location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
$('#data-loading').hide();
}
});
}
</script> </script>
\ No newline at end of file
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