def group_battles(self, cache):
list = sorted(cache.values(), key=get_match_id)
grouped = groupby(list, lambda x: x['match_id'])
groups = []
for key, group in grouped:
matches = []
battle = {}
first = True
for item in group:
if first:
first = False
battle['guild'] = item['op_guild']
battle['type'] = item['type']
battle['match_id'] = item['match_id']
matches.append(item)
battle['matches'] = matches
groups.append(battle)
return groups
评论列表
文章目录