1
0
mirror of synced 2024-11-27 23:50:47 +01:00

Make a couple of responses faster by fetching less achievement data.

This commit is contained in:
Jennifer Taylor 2021-09-07 17:56:46 +00:00
parent ef4a43be0e
commit 7560e30498
9 changed files with 16 additions and 75 deletions

View File

@ -949,17 +949,9 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX25grade') root = Node.void('IIDX25grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
def handle_IIDX25pc_common_request(self, request: Node) -> Node: def handle_IIDX25pc_common_request(self, request: Node) -> Node:

View File

@ -875,17 +875,9 @@ class IIDXCopula(IIDXCourse, IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX23grade') root = Node.void('IIDX23grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
# Invalid method # Invalid method

View File

@ -863,17 +863,9 @@ class IIDXPendual(IIDXCourse, IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX22grade') root = Node.void('IIDX22grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
# Invalid method # Invalid method

View File

@ -802,17 +802,9 @@ class IIDXRootage(IIDXCourse, IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX26grade') root = Node.void('IIDX26grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
def handle_IIDX26pc_common_request(self, request: Node) -> Node: def handle_IIDX26pc_common_request(self, request: Node) -> Node:

View File

@ -897,17 +897,9 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX24grade') root = Node.void('IIDX24grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
def handle_IIDX24pc_common_request(self, request: Node) -> Node: def handle_IIDX24pc_common_request(self, request: Node) -> Node:

View File

@ -986,17 +986,9 @@ class IIDXSpada(IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('IIDX21grade') root = Node.void('IIDX21grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
# Invalid method # Invalid method

View File

@ -962,17 +962,9 @@ class IIDXTricoro(IIDXBase):
) )
# Figure out number of players that played this ranking # Figure out number of players that played this ranking
all_achievements = self.data.local.user.get_all_achievements(self.game, self.version) all_achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=rank, achievementtype=index)
num_players = 0
for [_, ach] in all_achievements:
if ach.type != index:
continue
if ach.id != rank:
continue
num_players = num_players + 1
root = Node.void('grade') root = Node.void('grade')
root.set_attribute('pnum', str(num_players)) root.set_attribute('pnum', str(len(all_achievements)))
return root return root
# Invalid method # Invalid method

View File

@ -451,7 +451,7 @@ class PopnMusicLapistoria(PopnMusicBase):
) )
# Now, attempt to calculate ranking for this user for this run. # Now, attempt to calculate ranking for this user for this run.
all_courses = self.data.local.user.get_all_achievements(self.game, self.version, course_id, "course") all_courses = self.data.local.user.get_all_achievements(self.game, self.version, achievementid=course_id, achievementtype="course")
global_ranking = sorted(all_courses, key=lambda entry: entry[1].data.get_int('total_score'), reverse=True) global_ranking = sorted(all_courses, key=lambda entry: entry[1].data.get_int('total_score'), reverse=True)
pref_ranking = [c for c in global_ranking if c[1].data.get_int('pref') == pref] pref_ranking = [c for c in global_ranking if c[1].data.get_int('pref') == pref]
local_ranking = [c for c in global_ranking if c[1].data.get_int('lid') == machine.arcade] local_ranking = [c for c in global_ranking if c[1].data.get_int('lid') == machine.arcade]

View File

@ -3325,7 +3325,7 @@ class SoundVoltexHeavenlyHaven(
skill_course = Node.void('skill_course') skill_course = Node.void('skill_course')
game.add_child(skill_course) game.add_child(skill_course)
achievements = self.data.local.user.get_all_achievements(self.game, self.version) achievements = self.data.local.user.get_all_achievements(self.game, self.version, achievementtype="course")
courserates: Dict[Tuple[int, int], Dict[str, int]] = {} courserates: Dict[Tuple[int, int], Dict[str, int]] = {}
def getrates(season_id: int, course_id: int) -> Dict[str, int]: def getrates(season_id: int, course_id: int) -> Dict[str, int]:
@ -3339,9 +3339,6 @@ class SoundVoltexHeavenlyHaven(
} }
for _, achievement in achievements: for _, achievement in achievements:
if achievement.type != 'course':
continue
course_id = achievement.id % 100 course_id = achievement.id % 100
season_id = int(achievement.id / 100) season_id = int(achievement.id / 100)
rate = getrates(season_id, course_id) rate = getrates(season_id, course_id)