新增周报脚本
This commit is contained in:
parent
8ca93678d8
commit
fd007e88c3
@ -11,6 +11,12 @@ 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
|
||||||
|
|
||||||
@ -494,6 +500,51 @@ 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