tap order 数据写入mysql
This commit is contained in:
parent
69e48d98b5
commit
1ee10a5ea6
@ -10,7 +10,7 @@ import json
|
|||||||
|
|
||||||
define_logger("/data/logs/ops/taptap_report.log")
|
define_logger("/data/logs/ops/taptap_report.log")
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
import sys
|
||||||
|
|
||||||
class TapTapReport:
|
class TapTapReport:
|
||||||
def __init__(self, day):
|
def __init__(self, day):
|
||||||
@ -19,10 +19,34 @@ class TapTapReport:
|
|||||||
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
|
self.api_secret = "n9H4R32ZcjtSeN89ljCY6ESzTmOlnwwnOB3r4YsggnP5M1AXLtKtiS4sS1KKLOEQ"
|
||||||
self.tga = FromTga(url=self.url, token=self.api_secret)
|
self.tga = FromTga(url=self.url, token=self.api_secret)
|
||||||
self.day = day
|
self.day = day
|
||||||
|
self.bday = (datetime.datetime.strptime(self.day, "%Y-%m-%d") - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
def build_report(self):
|
def build_report(self):
|
||||||
pass
|
all = dict()
|
||||||
|
for item in (self.day, self.bday):
|
||||||
|
all.update(self.split_order_data(item))
|
||||||
|
print(all)
|
||||||
|
|
||||||
|
|
||||||
|
def split_order_data(self, day):
|
||||||
|
all_data = dict()
|
||||||
|
mydb = MysqlBase(**self.db_conf)
|
||||||
|
sql = f"select gameid,catename,`order`,date from taptap_order WHERE date={day}"
|
||||||
|
data = mydb.query(sql)
|
||||||
|
if data:
|
||||||
|
for line in data:
|
||||||
|
try:
|
||||||
|
gameid, catename, order, date = line
|
||||||
|
key = f"{str(gameid)}#{catename}"
|
||||||
|
temp = {}
|
||||||
|
temp['day'] = order
|
||||||
|
all_data[key] = temp
|
||||||
|
except Exception:
|
||||||
|
log.error(f"split line failed,values={line}", exc_info=True)
|
||||||
|
return all_data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_order(self):
|
def get_order(self):
|
||||||
sql = f"""
|
sql = f"""
|
||||||
@ -57,10 +81,13 @@ class TapTapReport:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
day = sys.argv[1]
|
||||||
|
else:
|
||||||
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
day = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
tap = TapTapReport(day)
|
tap = TapTapReport(day)
|
||||||
tap.get_order()
|
tap.get_order()
|
||||||
|
#tap.build_report()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user