Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vmusicchart-cms
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phạm Văn Đoan
vmusicchart-cms
Commits
9828719e
Commit
9828719e
authored
Apr 12, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cập nhật hiển thị thứ hạng
parent
9bed8390
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
189 additions
and
36 deletions
+189
-36
CmsRanking.php
application/controllers/backend/CmsRanking.php
+6
-2
MyHelper.php
application/libraries/MyHelper.php
+35
-0
Report_views_daily_model.php
application/models/Report_views_daily_model.php
+31
-0
Report_views_monthly_model.php
application/models/Report_views_monthly_model.php
+48
-20
Report_views_weekly_model.php
application/models/Report_views_weekly_model.php
+38
-0
list_by_daily_view.php
...ion/views/backend/ajax/cms_ranking/list_by_daily_view.php
+10
-4
list_by_monthly_view.php
...n/views/backend/ajax/cms_ranking/list_by_monthly_view.php
+10
-4
list_by_weekly_view.php
...on/views/backend/ajax/cms_ranking/list_by_weekly_view.php
+11
-6
No files found.
application/controllers/backend/CmsRanking.php
View file @
9828719e
...
...
@@ -24,6 +24,9 @@ class CmsRanking extends CI_Controller
$this
->
load
->
model
(
'crawler_listen_history_model'
);
}
/**
* BXH theo ngày ---------------------------------------------------------------------------------------------------
*/
public
function
listByDaily
()
{
$this
->
_data
[
'functionName'
]
=
'BXH Theo ngày'
;
...
...
@@ -48,6 +51,7 @@ class CmsRanking extends CI_Controller
$totalRecord
=
$this
->
report_views_daily_model
->
cmsCountAll
(
$fByName
);
$data
[
'pagination'
]
=
MyHelper
::
genPaginationLink
(
$totalRecord
,
$limit
,
$pageId
);
$data
[
'listData'
]
=
$this
->
report_views_daily_model
->
cmsGetPagination
(
$limit
,
$offset
,
$fByName
);
$data
[
'previousRanking'
]
=
$this
->
report_views_daily_model
->
previousRanking
(
$fByName
);
//
$this
->
load
->
view
(
'backend/ajax/cms_ranking/list_by_daily_view'
,
$data
);
}
...
...
@@ -78,9 +82,8 @@ class CmsRanking extends CI_Controller
$totalRecord
=
$this
->
report_views_weekly_model
->
cmsCountAll
(
$fByName
);
$data
[
'pagination'
]
=
MyHelper
::
genPaginationLink
(
$totalRecord
,
$limit
,
$pageId
);
$data
[
'listData'
]
=
$this
->
report_views_weekly_model
->
cmsGetPagination
(
$limit
,
$offset
,
$fByName
);
$data
[
'previousRanking'
]
=
$this
->
report_views_weekly_model
->
previousRanking
(
$fByName
);
//
// print_r($fByName);
$this
->
load
->
view
(
'backend/ajax/cms_ranking/list_by_weekly_view'
,
$data
);
}
...
...
@@ -110,6 +113,7 @@ class CmsRanking extends CI_Controller
$totalRecord
=
$this
->
report_views_monthly_model
->
cmsCountAll
(
$fByName
);
$data
[
'pagination'
]
=
MyHelper
::
genPaginationLink
(
$totalRecord
,
$limit
,
$pageId
);
$data
[
'listData'
]
=
$this
->
report_views_monthly_model
->
cmsGetPagination
(
$limit
,
$offset
,
$fByName
);
$data
[
'previousRanking'
]
=
$this
->
report_views_monthly_model
->
previousRanking
(
$fByName
);
//
$this
->
load
->
view
(
'backend/ajax/cms_ranking/list_by_monthly_view'
,
$data
);
}
...
...
application/libraries/MyHelper.php
View file @
9828719e
...
...
@@ -802,6 +802,40 @@ class MyHelper
return
$html
;
}
/**
* Hàm lấy thông tin so sánh tuần trước, tháng trước, ngày trước
*
* @param $track_id
* @param $order
* @param $previousRanking
*
* @return string
*/
public
static
function
getRankingCompare
(
$track_id
,
$order
,
$previousRanking
)
{
$compare
=
1000
;
if
(
is_array
(
$previousRanking
)
&&
count
(
$previousRanking
)
>
0
)
{
if
(
array_key_exists
(
$track_id
,
$previousRanking
))
{
$old_ranking
=
$previousRanking
[
$track_id
];
$compare
=
$old_ranking
-
$order
;
}
}
$resutl
=
''
;
if
(
$compare
==
1000
)
{
$resutl
=
'<span>Mới</span>'
;
}
else
{
if
(
$compare
<
0
)
{
$resutl
=
'<i class="fa fa-caret-down" aria-hidden="true" style="font-size: 20px; color: #f50202"></i> '
.
abs
(
$compare
);
}
else
if
(
$compare
==
0
)
{
$resutl
=
'<i class="fa fa-minus" aria-hidden="true" style="font-size: 20px; color: #999999"></i>'
;
}
else
{
$resutl
=
'<i class="fa fa-caret-up" aria-hidden="true" style="font-size: 20px; color: #22ba4e"></i> '
.
$compare
;
}
}
return
$resutl
;
}
}
/* End */
\ No newline at end of file
application/models/Report_views_daily_model.php
View file @
9828719e
...
...
@@ -50,4 +50,34 @@ class Report_views_daily_model extends CI_Model
return
$query
->
result_array
();
}
/**
* Hàm lấy xếp hạng tháng trước để so sánh tăng/giảm hạng
*
* @param $date
* @return array
*/
public
function
previousRanking
(
$date
)
{
$this
->
db
->
select
(
'track_id, ranking, month, year'
);
$this
->
db
->
from
(
$this
->
_table
);
if
(
$date
!=
null
)
{
$yesterday
=
date
(
'Y-m-d'
,
strtotime
(
$date
)
-
86400
);
$this
->
db
->
where
(
'date'
,
$yesterday
);
}
$this
->
db
->
where
(
'ranking <='
,
100
);
$query
=
$this
->
db
->
get
();
$data
=
$query
->
result_array
();
$result
=
[];
if
(
$data
)
{
foreach
(
$data
as
$key
=>
$val
)
{
$result
[
$val
[
'track_id'
]]
=
$val
[
'ranking'
];
}
}
return
$result
;
}
}
\ No newline at end of file
application/models/Report_views_monthly_model.php
View file @
9828719e
...
...
@@ -2,8 +2,7 @@
class
Report_views_monthly_model
extends
CI_Model
{
protected
$_table
=
'reports_views_monthly'
;
protected
$_table_new
=
'report_views_monthly_new'
;
protected
$_table
=
'report_views_monthly_new'
;
public
function
__construct
(){
parent
::
__construct
();
...
...
@@ -29,44 +28,72 @@ class Report_views_monthly_model extends CI_Model
track_user.name AS singer_name2, tracks.title AS name_song,
GROUP_CONCAT(track_user.`name` SEPARATOR ",") AS all_name, tracks.art AS art'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
join
(
'track_user'
,
'track_user.track_id =
reports_views_monthly
.track_id'
,
'left'
);
$this
->
db
->
join
(
'tracks'
,
'tracks.id =
reports_views_monthly
.track_id'
,
'left'
);
$this
->
db
->
join
(
'track_user'
,
'track_user.track_id =
'
.
$this
->
_table
.
'
.track_id'
,
'left'
);
$this
->
db
->
join
(
'tracks'
,
'tracks.id =
'
.
$this
->
_table
.
'
.track_id'
,
'left'
);
$this
->
db
->
join
(
'users u1'
,
'u1.id = track_user.user_id'
,
'left'
);
if
(
$name
!=
null
)
{
$data
=
explode
(
'-'
,
$name
);
$this
->
db
->
where
(
'month'
,
$data
[
0
]);
$this
->
db
->
where
(
'year'
,
$data
[
1
]);
}
else
{
// $this->db->select('month, year');
// $this->db->from($this->_table);
// $this->db->distinct($this->_table . '.month');
// $this->db->order_by( $this->_table . '.year desc');
// $this->db->order_by( $this->_table . '.month desc');
// $this->db->limit(1);
// $query = $this->db->get();
// $data = $query->result_array();
// $this->db->where('month', $data[0]['month']);
// $this->db->where('year', $data[0]['year']);
}
$this
->
db
->
group_by
(
'reports_views_monthly
.id'
);
$this
->
db
->
group_by
(
$this
->
_table
.
'
.id'
);
$this
->
db
->
order_by
(
$this
->
_table
.
'.total_point'
,
'desc'
);
// $this->db->order_by($this->_table . '.title', 'asc');
$this
->
db
->
limit
(
$record
);
$query
=
$this
->
db
->
get
();
return
$query
->
result_array
();
}
public
function
selectSearch
()
{
public
function
selectSearch
()
{
error_log
(
'a:'
.
$this
->
_table
);
$this
->
db
->
select
(
'month, year'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
distinct
(
$this
->
_table
.
'.month'
);
$this
->
db
->
order_by
(
$this
->
_table
.
'.year desc'
);
$this
->
db
->
order_by
(
$this
->
_table
.
'.month desc'
);
$this
->
db
->
limit
(
3
);
$query
=
$this
->
db
->
get
();
return
$query
->
result_array
();
}
/**
* Hàm lấy xếp hạng tháng trước để so sánh tăng/giảm hạng
*
* @param $month_year
* @return array
*/
public
function
previousRanking
(
$month_year
)
{
$this
->
db
->
select
(
'track_id, order, month, year'
);
$this
->
db
->
from
(
$this
->
_table
);
if
(
$month_year
!=
null
)
{
$data
=
explode
(
'-'
,
$month_year
);
$month
=
intval
(
$data
[
0
]);
$year
=
intval
(
$data
[
1
]);
if
(
$month
==
1
)
{
$month
=
12
;
$year
=
$year
-
1
;
}
else
{
$month
=
$month
-
1
;
}
$this
->
db
->
where
(
'month'
,
$month
);
$this
->
db
->
where
(
'year'
,
$year
);
}
$this
->
db
->
where
(
'order <='
,
100
);
$query
=
$this
->
db
->
get
();
$data
=
$query
->
result_array
();
$result
=
[];
if
(
$data
)
{
foreach
(
$data
as
$key
=>
$val
)
{
$result
[
$val
[
'track_id'
]]
=
$val
[
'order'
];
}
}
return
$result
;
}
}
\ No newline at end of file
application/models/Report_views_weekly_model.php
View file @
9828719e
...
...
@@ -61,4 +61,41 @@ class Report_views_weekly_model extends CI_Model
return
$query
->
result_array
();
}
/**
* Hàm lấy xếp hạng tuần trước để so sánh tăng/giảm hạng
*
* @param $week_year
* @return array
*/
public
function
previousRanking
(
$week_year
)
{
$this
->
db
->
select
(
'track_id, order, week, year'
);
$this
->
db
->
from
(
$this
->
_table
);
if
(
$week_year
!=
null
)
{
$data
=
explode
(
'-'
,
$week_year
);
$week
=
intval
(
$data
[
0
]);
$year
=
intval
(
$data
[
1
]);
if
(
$week
==
1
)
{
return
[];
}
else
{
$week
=
$week
-
1
;
}
$this
->
db
->
where
(
'week'
,
$week
);
$this
->
db
->
where
(
'year'
,
$year
);
}
$this
->
db
->
where
(
'order <='
,
100
);
$query
=
$this
->
db
->
get
();
$data
=
$query
->
result_array
();
$result
=
[];
if
(
$data
)
{
foreach
(
$data
as
$key
=>
$val
)
{
$result
[
$val
[
'track_id'
]]
=
$val
[
'order'
];
}
}
return
$result
;
}
}
\ No newline at end of file
application/views/backend/ajax/cms_ranking/list_by_daily_view.php
View file @
9828719e
...
...
@@ -2,8 +2,8 @@
<table
class=
"table table-striped table-bordered table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center"
>
TT
</th>
<
!--<th style="text-align: center">#ID</th>--
>
<th
style=
"text-align: center"
>
Xếp hạng
</th>
<
th
style=
"text-align: center"
>
Đánh giá
</th
>
<th
style=
"text-align: center"
>
Ảnh
</th>
<th
style=
"text-align: center"
><i
class=
"fa fa-music color-red"
></i>
Tên bài hát
</th>
<th
style=
"text-align: center"
><i
class=
"fa fa-line-chart color-red"
></i>
Lịch sử
</th>
...
...
@@ -19,9 +19,15 @@
<?php
if
(
count
(
$listData
)
>
0
)
:
foreach
(
$listData
as
$key
=>
$data
)
:
?>
<tr>
<td
style=
"text-align: center"
>
<?php
echo
(
$key
+
1
+
$offset
);
?>
</td>
<!--<td style="text-align: center">#
<?php
/*echo $data['track_id']; */
?>
</td>-->
<td
style=
"text-align: center"
>
<?php
echo
MyHelper
::
getRankingCompare
(
$data
[
'track_id'
],
$data
[
'ranking'
],
$previousRanking
)
?>
</td>
<td
style=
"text-align: center"
><img
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$data
[
'art'
]);
?>
"
style=
"max-width: 50px; max-height: 50px"
></td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
]
.
' (#'
.
$data
[
'track_id'
]
.
')'
;
?>
</td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
];
?>
<br>
<span
style=
"color: #adadad"
>
ID:
<?php
echo
$data
[
'track_id'
];
?>
</span>
</td>
<td
style=
"text-align: center"
>
<a
href=
"javascript:void(0)"
title=
"Click để xem lịch sử lượt nghe"
onclick=
"showHistory(
<?php
echo
$data
[
'track_id'
]
?>
, '
<?php
echo
$data
[
'name_song'
]
?>
')"
>
...
...
application/views/backend/ajax/cms_ranking/list_by_monthly_view.php
View file @
9828719e
...
...
@@ -2,8 +2,8 @@
<table
class=
"table table-striped table-bordered table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center"
>
TT
</th>
<th
style=
"text-align: center"
>
#ID
</th>
<th
style=
"text-align: center"
>
Xếp hạng
</th>
<th
style=
"text-align: center"
>
Đánh giá
</th>
<th
style=
"text-align: center"
>
Ảnh
</th>
<th
style=
"text-align: center"
>
Tên bài hát
</th>
<th
style=
"text-align: center"
>
Ca sĩ
</th>
...
...
@@ -14,9 +14,15 @@
<?php
if
(
count
(
$listData
)
>
0
)
:
foreach
(
$listData
as
$key
=>
$data
)
:
?>
<tr>
<td
style=
"text-align: center"
>
<?php
echo
(
$key
+
1
+
$offset
);
?>
</td>
<td
style=
"text-align: center"
>
#
<?php
echo
$data
[
'track_id'
];
?>
</td>
<td
style=
"text-align: center"
>
<?php
echo
MyHelper
::
getRankingCompare
(
$data
[
'track_id'
],
$data
[
'order'
],
$previousRanking
)
?>
</td>
<td
style=
"text-align: center"
><img
style=
"max-width: 50px"
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$data
[
'art'
]);
?>
"
></td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
];
?>
</td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
];
?>
<br>
<span
style=
"color: #adadad"
>
ID:
<?php
echo
$data
[
'track_id'
];
?>
</span>
</td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'all_name'
];
?>
</td>
<td
style=
"text-align: right"
>
<?php
echo
number_format
(
$data
[
'total_point'
],
0
,
','
,
'.'
);
?>
</td>
</tr>
...
...
application/views/backend/ajax/cms_ranking/list_by_weekly_view.php
View file @
9828719e
...
...
@@ -2,8 +2,8 @@
<table
class=
"table table-striped table-bordered table-hover"
>
<thead>
<tr>
<th
style=
"text-align: center"
>
TT
</th>
<th
style=
"text-align: center"
>
#ID
</th>
<th
style=
"text-align: center"
>
Xếp hạng
</th>
<th
style=
"text-align: center"
>
Đánh giá
</th>
<th
style=
"text-align: center"
>
Ảnh
</th>
<th
style=
"text-align: center"
>
Tên bài hát
</th>
<th
style=
"text-align: center"
>
Ca sĩ
</th>
...
...
@@ -14,9 +14,15 @@
<?php
if
(
count
(
$listData
)
>
0
)
:
foreach
(
$listData
as
$key
=>
$data
)
:
?>
<tr>
<td
style=
"text-align: center"
>
<?php
echo
(
$key
+
1
+
$offset
);
?>
</td>
<td
style=
"text-align: center"
>
#
<?php
echo
$data
[
'track_id'
];
?>
</td>
<td
style=
"text-align: center"
>
<?php
echo
MyHelper
::
getRankingCompare
(
$data
[
'track_id'
],
$data
[
'order'
],
$previousRanking
)
?>
</td>
<td
style=
"text-align: center"
><img
style=
"max-width: 50px"
src=
"
<?php
echo
MyHelper
::
getArtByTrack
(
$data
[
'art'
]);
?>
"
></td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
];
?>
</td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'name_song'
];
?>
<br>
<span
style=
"color: #adadad"
>
ID:
<?php
echo
$data
[
'track_id'
];
?>
</span>
</td>
<td
style=
"text-align: left"
>
<?php
echo
$data
[
'all_name'
];
?>
</td>
<td
style=
"text-align: right"
>
<?php
echo
number_format
(
$data
[
'total_point'
],
0
,
','
,
'.'
);
?>
</td>
</tr>
...
...
@@ -30,4 +36,4 @@
</table>
</div>
<!-- /.row -->
<div
style=
"text-align: center;"
>
<?php
//
echo
$pagination
;
?>
</div>
\ No newline at end of file
<div
style=
"text-align: center;"
>
<?php
//echo $pagination; ?></div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment