diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 24e7d6c..90c6d3c 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -468,10 +468,24 @@ async def event_model( res[0][i] = ad # 如是充值排行,限制返回300条 if res[0].get('event_name','') == '充值排行': - res[0]['groups'] = res[0]['groups'][0:300] - res[0]['values'] = res[0]['values'][0:300] - res[0]['sum'] = res[0]['sum'][0:300] - res[0]['avg'] = res[0]['avg'][0:300] + res[0]['groups'] = res[0]['groups'][0:100] + # 处理sql查询后的数据 + res_list = [] + for j in range(len(res[0]['groups'])): + res_list.append("'" + res[0]['groups'][j][1:len(res[0]['groups'][j]) - 1] + "'") + res_list2 = ','.join(str(i) for i in res_list) + # 将account_id查的数据通过新sql替换成玩家角色名 + a_list = await ckdb.execute( + f""" select last_value(role_name) as role_name , `#account_id` from {game}.event where `#event_name` = 'pay' and `#account_id` in ({str(res_list2)}) group by `#account_id`""") + for k in range(len(res[0]['groups'])): + for h in range(len(a_list)): + c1 = res[0]['groups'][k][1:len(res[0]['groups'][k]) - 1] + c2 = a_list.get(h).get("#account_id") + if c1 == c2: + res[0]['groups'][k] = a_list.get(h).get("role_name") + res[0]['values'] = res[0]['values'][0:100] + res[0]['sum'] = res[0]['sum'][0:100] + res[0]['avg'] = res[0]['avg'][0:100] return schemas.Msg(code=0, msg='ok', data=res)