This commit is contained in:
pengtao 2019-11-21 17:21:32 +08:00
parent 9373f843c4
commit b9352026ec
2 changed files with 38 additions and 23 deletions

View File

@ -507,33 +507,42 @@ class TapWeeklyReport:
self.db_conn = MysqlBase(**db_conf) self.db_conn = MysqlBase(**db_conf)
self.limit = 20 self.limit = 20
def get_weekly_days(self): # def get_weekly_days(self):
weekly_days = [] # weekly_days = []
for i in range(0, 7): # for i in range(0, 7):
current_day = (datetime.datetime.strptime(self.day, '%Y-%m-%d') - datetime.timedelta(days=i)).strftime( # current_day = (datetime.datetime.strptime(self.day, '%Y-%m-%d') - datetime.timedelta(days=i)).strftime(
'%Y-%m-%d') # '%Y-%m-%d')
weekly_days.append(current_day) # weekly_days.append(current_day)
return weekly_days # return weekly_days
def build(self): def build(self):
weekly_day = json.dumps(self.get_weekly_days()).strip('[]') # weekly_day = json.dumps(self.get_weekly_days()).strip('[]')
tap_types = ("new", "download", "reserve", "sell", "played") tap_types = ("new", "download", "reserve", "sell", "played")
all_data = defaultdict(list) all_data = defaultdict(list)
for tap_type in tap_types: for tap_type in tap_types:
sql = f"""select sql = f"""select
gameid, gameid,
title, title as "名称",
min(`order`), sum(diff_order), sum(diff_watch), sum(diff_download), sum(diff_topic), score `order` as "当前排名",
from min_order as "最高排名",
taptap_collect max_order as "最低排名",
where diff_order as "排名变动",
catename='{tap_type}' score as "评分",
and date in ({weekly_day}) tags as "游戏标签",
group by watch as "关注数",
gameid download as "下载数",
order by sell as "购买数",
sum(diff_order) desc limit {self.limit};""" reserve as "预约数",
review as "评论数",
topic as "话题"
from
tap_weekly
where
catename='{tap_type}'
and date = {self.day}
order by
`order` desc limit {self.limit};"""
data = self.db_conn.query(sql) data = self.db_conn.query(sql)
if data: if data:

View File

@ -23,11 +23,17 @@
<th>游戏ID</th> <th>游戏ID</th>
<th>游戏名称</th> <th>游戏名称</th>
<th>排名</th> <th>排名</th>
<th>最高排名</th>
<th>最低排名</th>
<th>排名变动</th> <th>排名变动</th>
<th>关注变动</th>
<th>下载变化</th>
<th>评论变化</th>
<th>评分</th> <th>评分</th>
<th>游戏标签</th>
<th>关注数</th>
<th>下载数</th>
<th>购买数</th>
<th>预约数</th>
<th>评论数</th>
<th>话题</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>