# -*- coding: utf-8 -*- from mytask.tga import GetFromTga import logging log = logging.getLogger(__name__) tap_items = {'daily_challenge': {'button_name': 'home', 'button_subname': 'bt_challenge'}, 'daily_start': {'button_name': 'dailyChallenge', 'button_subname': 'bt_start'}, 'daily_rank': {'button_name': 'home', 'button_subname': 'bt_rank'}, 'bt_achieve': {'button_name': 'home', 'button_subname': 'bt_achieve'}, 'bt_finiteReward': {'button_name': 'home', 'button_subname': 'bt_finiteReward'}, 'getReward': {'button_name': 'finiteReward', 'button_subname': 'bt_getReward'}, 'bt_onlineReward': {'button_name': 'home', 'button_subname': 'bt_onlineReward'}, 'bt_invite': {'button_name': 'inviteFriend', 'button_subname': 'bt_invite'}, 'bt_pet': {'button_name': 'home', 'button_subname': 'bt_pet'}, } class TGA_event(GetFromTga): def event_shop(self): sql = f"""select cast(json_extract(button_param,'$.id') as int) as id, count(1) from v_event_{self.suffix} where gameid='{self.gameid}' and "$part_event"='event_11_31' and "button_name"='shop' and "button_subname"='bt_compbine' and "$part_date"='{self.date}' group by cast(json_extract(button_param,'$.id') as int)""" out = self.tga.get_data(sql) if out: for line in out: if line: temp = {} try: temp['id'], temp['num'] = line except Exception: log.error(f"write {line} 2 tga failed!", exc_info=True) if temp: self.write_tga_files(temp) def event_shop_new(self): sql = f"""select cast(json_extract(button_param,'$.id') as int) as id, count(1) from v_event_{self.suffix} where gameid='{self.gameid}' and "$part_event"='event_11_31' and "button_name"='shop' and "button_subname"='bt_compbine' and "$part_date"='{self.date}' and "$part_date"='{self.date}' and account_register_date BETWEEN timestamp'{self.date} 00:00:00' and timestamp'{self.date} 23:59:59' group by cast(json_extract(button_param,'$.id') as int)""" out = self.tga.get_data(sql) if out: for line in out: if line: temp = {} try: temp['id'], temp['num'] = line if temp: self.write_tga_files(temp) except Exception: log.error(f"write {line} 2 tga failed!", exc_info=True) def event_tap(self): for item in tap_items: 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"='{tap_items[item]['button_name']}' and button_subname= '{tap_items[item]['button_subname']}' and "$part_date"='{self.date}'""" out = self.tga.get_data(sql) for line in out: if line: temp = {} try: temp['name'] = item temp['num'] = line[0] if temp: self.write_tga_files(temp) except Exception: log.error(f"write {line} 2 tga failed!", exc_info=True) def event_tap_new(self): for item in tap_items: 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"='{tap_items[item]['button_name']}' and button_subname= '{tap_items[item]['button_subname']}' and "$part_date"='{self.date}' and account_register_date BETWEEN timestamp'{self.date} 00:00:00' and timestamp'{self.date} 23:59:59'""" out = self.tga.get_data(sql) for line in out: if line: temp = {} try: temp['name'] = item temp['num'] = line[0] if temp: self.write_tga_files(temp) except Exception: log.error(f"write {line} 2 tga failed!", exc_info=True) def run_event_shop_1016(kwargs): mytga = TGA_event(**kwargs) mytga.event_shop() def run_event_shop_new_1016(kwargs): mytga = TGA_event(**kwargs) mytga.event_shop_new() def run_event_tap_1016(kwargs): mytga = TGA_event(**kwargs) mytga.event_tap() def run_event_tap_new_1016(kwargs): mytga = TGA_event(**kwargs) mytga.event_tap_new()