103 lines
4.5 KiB
Python
103 lines
4.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
from mytask.tga import GetFromTga
|
|
import logging
|
|
import json
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class TGA_event(GetFromTga):
|
|
def event_tap(self):
|
|
items = {'mainrankbtn': '登录界面:排行榜点击次数', 'mainshareitembtn': '登录界面:分享得道具点击次数', 'mainvsbtn': '登录界面:好友对战点击次数',
|
|
'gamerankbtn': '游戏界面:排行榜点击次数', 'settingbtn': '游戏界面:设置点击次数', 'clickitembtn|1': '锤子点击次数',
|
|
'clickitembtn|0': '贪吃娃点击次数', 'useskill': '小女孩点击次数', 'playrebornbtn': '复活继续点击次数',
|
|
'playagainbtn': '再玩一局点击次数', }
|
|
tap_data = {}
|
|
for item in items.keys():
|
|
if len(item.split("|")) == 2:
|
|
sql = f"""SELECT
|
|
count(1)
|
|
from
|
|
v_event_{self.suffix}
|
|
where
|
|
gameid='{self.gameid}'
|
|
and "channel"='{self.channelid}'
|
|
and "$part_event"='event_11_31'
|
|
and "button_name"='{item.split("|")[0]}'
|
|
and cast(json_extract(button_param,'$.itemid') as int) = {item.split("|")[1]}
|
|
and "$part_date"='{self.date}'"""
|
|
else:
|
|
sql = f"""SELECT
|
|
count(1)
|
|
from
|
|
v_event_{self.suffix}
|
|
where
|
|
gameid='{self.gameid}'
|
|
and "channel"='{self.channelid}'
|
|
and "$part_event"='event_11_31'
|
|
and "button_name"='{item}'
|
|
and "$part_date"='{self.date}'"""
|
|
|
|
try:
|
|
out = self.tga.get_data(sql)
|
|
tap_data[item] = out[0][0]
|
|
except Exception:
|
|
log.error("get data from tga failed!", exc_info=True)
|
|
try:
|
|
self.write_tga_files(tap_data)
|
|
except Exception:
|
|
log.error(f"write {json.dumps(tap_data)} 2 tga failed!", exc_info=True)
|
|
|
|
def event_tap_new(self):
|
|
items = {'mainrankbtn': '登录界面:排行榜点击次数', 'mainshareitembtn': '登录界面:分享得道具点击次数', 'mainvsbtn': '登录界面:好友对战点击次数',
|
|
'gamerankbtn': '游戏界面:排行榜点击次数', 'settingbtn': '游戏界面:设置点击次数', 'clickitembtn|1': '锤子点击次数',
|
|
'clickitembtn|0': '贪吃娃点击次数', 'useskill': '小女孩点击次数', 'playrebornbtn': '复活继续点击次数',
|
|
'playagainbtn': '再玩一局点击次数', }
|
|
tap_data = {}
|
|
for item in items.keys():
|
|
if len(item.split("|")) == 2:
|
|
sql = f"""SELECT
|
|
count(1)
|
|
from
|
|
v_event_{self.suffix}
|
|
where
|
|
gameid='{self.gameid}'
|
|
and "channel"='{self.channelid}'
|
|
and "$part_event"='event_11_31'
|
|
and "button_name"='{item.split("|")[0]}'
|
|
and cast(json_extract(button_param,'$.itemid') as int) = {item.split("|")[1]}
|
|
and "$part_date"='{self.date}' and account_register_date BETWEEN timestamp'{self.date} 00:00:00'
|
|
and timestamp'{self.date} 23:59:59'"""
|
|
else:
|
|
sql = f"""SELECT
|
|
count(1)
|
|
from
|
|
v_event_{self.suffix}
|
|
where
|
|
gameid='{self.gameid}'
|
|
and "channel"='{self.channelid}'
|
|
and "$part_event"='event_11_31'
|
|
and "button_name"='{item}'
|
|
and "$part_date"='{self.date}'
|
|
and account_register_date BETWEEN timestamp'{self.date} 00:00:00'
|
|
and timestamp'{self.date} 23:59:59'"""
|
|
try:
|
|
out = self.tga.get_data(sql)
|
|
tap_data[item] = out[0][0]
|
|
except Exception:
|
|
log.error("get data from tga failed!", exc_info=True)
|
|
try:
|
|
self.write_tga_files(tap_data)
|
|
except Exception:
|
|
log.error(f"write {json.dumps(tap_data)} 2 tga failed!", exc_info=True)
|
|
|
|
|
|
def run_event_tap_1004(kwargs):
|
|
mytga = TGA_event(**kwargs)
|
|
mytga.event_tap()
|
|
|
|
|
|
def run_event_tap_new_1004(kwargs):
|
|
mytga = TGA_event(**kwargs)
|
|
mytga.event_tap_new()
|