diff --git a/Readme.md b/Readme.md index 44f60de..c2e35ed 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ 数据展示接口 -#### 0、检查检查 +#### 0、检查接口 ##### 接口地址 ##### 请求方式:get ##### 请求示范 @@ -60,6 +60,7 @@ http://154.8.214.202:5022/webapp/index.php?c=Ops&a=getmethods&gameid=2001 } ] } + #### 2、按方法和日期返回某天的数据 ##### 接口地址 @@ -131,7 +132,7 @@ http://154.8.214.202:5022/webapp/index.php?c=Ops&a=getreport&gameid=2001&channel ##### 接口地址 -http://154.8.214.202:5022/webapp/index.php?c=Ops&a=getreport&gameid=2001&channelid=6001&methods=tap_2001×=2019-08-13 +http://154.8.214.202:5022/webapp/index.php?c=Ops&a=getreport&gameid=2001&channelid=6001&methods=share&b_times="2019-08-13 12:00:00" ##### 返回格式:json @@ -145,11 +146,11 @@ http://154.8.214.202:5022/webapp/index.php?c=Ops&a=getreport&gameid=2001&channel | ------------ | -------- | ---- | ----------------------------------------- | | gameid | int | 是 | 游戏ID | | channelid | int | 是 | 渠道ID | -| ad_channelid | string | 否 | 广告上报的关键词 | +| ad_channelid | string | 是 | 广告上报的关键词 | | method | string | 是 | 查询数据类型 | | time_partice | int | 是 | 查询时间颗粒(0=1分钟,1=5分钟,2=1小时) | -| time_begin | datetime | 是 | 开始时间 | -| time_end | datetime | 是 | 结束时间 | +| b_time | datetime | 是 | 开始时间 | +| e_time | datetime | 是 | 结束时间 | @@ -176,3 +177,48 @@ select time,num from user_online where env='prod' and gameid='1013' and time >'2 如查询结果为空,则返回状态码200,内容为空 +#### 4、返回可用的实时数据方法(按gameid排查)及返回方法的字段定义 + +##### 接口地址 + +http://154.8.214.202:5022/webapp/index.php + +##### 返回格式:json + +##### 请求方式:get + +##### 请求示范 + +http://154.8.214.202:5022/webapp/index.php?c=Ops&a=GetRealMethods&gameid=2001 + +##### 请求参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------ | +| gameid | string | 是 | 查询的游戏ID | +| channelid | string | 否 | 默认为6001(微信) | +| | | | | + +##### 返回参数说明 + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ------ | ---- | ---------- | +| gamename | string | 是 | 游戏中文名 | +| methods | String | 是 | 方法名 | +| methods_name | String | 是 | 方法显示名 | + +{ + "errcode": 0, + "errmsg": "", + "result": [ + { + "methods": "stage", + "method_display": "关卡通关记录", + }, + { + "methods": "stage", + "method_display": "关卡通关记录", + } + ] +} + diff --git a/mytask/tasks_1004.py b/mytask/tasks_1004.py index dc3342f..47cb3db 100644 --- a/mytask/tasks_1004.py +++ b/mytask/tasks_1004.py @@ -12,7 +12,6 @@ class TGA_event(GetFromTga): 'gamerankbtn': '游戏界面:排行榜点击次数', 'settingbtn': '游戏界面:设置点击次数', 'clickitembtn|1': '锤子点击次数', 'clickitembtn|0': '贪吃娃点击次数', 'useskill': '小女孩点击次数', 'playrebornbtn': '复活继续点击次数', 'playagainbtn': '再玩一局点击次数', } - tap_data = {} for item in items.keys(): if len(item.split("|")) == 2: sql = f"""SELECT @@ -40,20 +39,19 @@ class TGA_event(GetFromTga): try: out = self.tga.get_data(sql) - tap_data[item] = out[0][0] + temp = {} + temp['name'] = items[item] + temp['num'] = out[0][0] + self.write_tga_files(temp) 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 @@ -83,13 +81,13 @@ class TGA_event(GetFromTga): and timestamp'{self.date} 23:59:59'""" try: out = self.tga.get_data(sql) - tap_data[item] = out[0][0] + temp={} + temp['name']=items[item] + temp['num']=out[0][0] + self.write_tga_files(temp) 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):