remove no use
This commit is contained in:
parent
1d957828b8
commit
21fafdedb3
@ -11,12 +11,6 @@ from ops.plog import define_logger
|
|||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
from ops.mmysql import MysqlBase
|
|
||||||
import json
|
|
||||||
|
|
||||||
db_conf = {'user': 'mytga', 'pswd': 'gzVwh4HGR68G', 'host': '10.10.3.5', 'db': 'external_data'}
|
|
||||||
|
|
||||||
|
|
||||||
define_logger("/data/logs/ops/daily_report.log")
|
define_logger("/data/logs/ops/daily_report.log")
|
||||||
import pdb
|
import pdb
|
||||||
|
|
||||||
@ -101,29 +95,6 @@ def send_dailyreport():
|
|||||||
return jsonify("get Data Failed!")
|
return jsonify("get Data Failed!")
|
||||||
|
|
||||||
|
|
||||||
@app.route('/send-tapweekly')
|
|
||||||
def send_tapweekly():
|
|
||||||
title = "TAP周报"
|
|
||||||
day = request.args.get('day')
|
|
||||||
recipients = ["pengtao@kingsome.cn"]
|
|
||||||
msg = Message(title, sender=sender, recipients=recipients)
|
|
||||||
twr = TapWeeklyReport(day)
|
|
||||||
data = twr.build()
|
|
||||||
print(data)
|
|
||||||
# data[day] = day
|
|
||||||
msg.subject = f"TAPTAP_{day}_游戏周报"
|
|
||||||
if data:
|
|
||||||
msg.html = render_template('tap_weekly.html', data=data, day=day)
|
|
||||||
|
|
||||||
thread = Thread(target=send_async_email, args=[app, msg])
|
|
||||||
thread.start()
|
|
||||||
|
|
||||||
return jsonify("邮件发送成功")
|
|
||||||
else:
|
|
||||||
return jsonify("get Data Failed!")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Report:
|
class Report:
|
||||||
def __init__(self, day, project):
|
def __init__(self, day, project):
|
||||||
self.day = day
|
self.day = day
|
||||||
@ -499,51 +470,6 @@ class Report:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TapWeeklyReport:
|
|
||||||
def __init__(self, day):
|
|
||||||
self.day = day
|
|
||||||
self.db_conn = MysqlBase(**db_conf)
|
|
||||||
self.limit = 20
|
|
||||||
|
|
||||||
def get_weekly_days(self):
|
|
||||||
weekly_days = []
|
|
||||||
for i in range(0, 7):
|
|
||||||
current_day = (datetime.datetime.strptime(self.day, '%Y-%m-%d') - datetime.timedelta(days=i)).strftime(
|
|
||||||
'%Y-%m-%d')
|
|
||||||
weekly_days.append(current_day)
|
|
||||||
return weekly_days
|
|
||||||
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
weekly_day = json.dumps(self.get_weekly_days()).strip('[]')
|
|
||||||
tap_types = ("new", "download", "reserve", "sell", "played")
|
|
||||||
all_data = defaultdict(list)
|
|
||||||
for tap_type in tap_types:
|
|
||||||
sql = f"""select
|
|
||||||
gameid,
|
|
||||||
title,
|
|
||||||
min(`order`), sum(diff_order), sum(diff_watch), sum(diff_download), sum(diff_topic), score
|
|
||||||
from
|
|
||||||
taptap_collect
|
|
||||||
where
|
|
||||||
catename='{tap_type}'
|
|
||||||
and date in ({weekly_day})
|
|
||||||
group by
|
|
||||||
gameid
|
|
||||||
order by
|
|
||||||
sum(diff_order) desc limit {self.limit};"""
|
|
||||||
|
|
||||||
data = self.db_conn.query(sql)
|
|
||||||
if data:
|
|
||||||
all_data[tap_type].append(data) # print(f"{tap_type}\t{data}")
|
|
||||||
return all_data
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
data = self.build()
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
project = 'mini_games'
|
project = 'mini_games'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user