forked from Hay1tsme/artemis
ongeki: proper handling of music ranking list
This commit is contained in:
@ -157,19 +157,27 @@ class OngekiBase:
|
||||
return {"type": data["type"], "length": 0, "gameIdlistList": []}
|
||||
|
||||
async def handle_get_game_ranking_api_request(self, data: Dict) -> Dict:
|
||||
game_ranking_list = await self.data.static.get_ranking_list(self.version)
|
||||
|
||||
ranking_list = []
|
||||
for music in game_ranking_list:
|
||||
tmp = music._asdict()
|
||||
ranking_list.append(tmp)
|
||||
try:
|
||||
date = datetime.now(pytz.timezone('Asia/Tokyo')) - timedelta(days=1,hours=7)
|
||||
|
||||
if ranking_list is None:
|
||||
return {"length": 0, "gameRankingList": []}
|
||||
return {
|
||||
"type": data["type"],
|
||||
"gameRankingList": ranking_list,
|
||||
}
|
||||
# type 1 - current ranking; type 2 - previous ranking
|
||||
if data["type"] == 2:
|
||||
date = date - timedelta(1)
|
||||
|
||||
rankings = await self.data.score.get_rankings(date)
|
||||
|
||||
if not rankings or (data["type"] == 1 and len(rankings) < 10):
|
||||
return {"type": data["type"], "gameRankingList": []}
|
||||
|
||||
ranking_list = []
|
||||
for count, music_id in rankings:
|
||||
ranking_list.append({"id": music_id, "point": count, "userName": ""})
|
||||
|
||||
return {"type": data["type"], "gameRankingList": ranking_list}
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error while getting game ranking: {e}")
|
||||
return {"type": data["type"], "gameRankingList": []}
|
||||
|
||||
async def handle_get_game_point_api_request(self, data: Dict) -> Dict:
|
||||
get_game_point = await self.data.static.get_static_game_point()
|
||||
|
Reference in New Issue
Block a user