diff --git a/titles/idac/controller/season3/user_controller.py b/titles/idac/controller/season3/user_controller.py index 0e95733..4ed2147 100644 --- a/titles/idac/controller/season3/user_controller.py +++ b/titles/idac/controller/season3/user_controller.py @@ -102,12 +102,17 @@ class IDACSeason3UserController(IDACSeason2UserController): claimed_rewards = await self.team_service.claimed_league_rewards(user_id) if not claimed_rewards: + team_id = team_info.team_id + # get past league info - last_league_info = await self.team_service.get_past_league_info(team_info.team_id, user_id) + last_league_info = await self.team_service.get_past_league_info(team_id, user_id) # generate league rewards based on the last league league_rewards = self.team_service.generate_league_rewards(last_league_info) + # claim rewards for the user to prevent duplicate claiming + await self.team_service.update_past_league_rewards(user_id, team_id) + resp.team_info = team_info resp.league_info = league_info resp.league_rewards = league_rewards @@ -126,12 +131,6 @@ class IDACSeason3UserController(IDACSeason2UserController): await super().handle_update_login_request(data, headers) ) - user_id = req_headers.session - - # mark league rewards as received - if len(req.league_rewards_id_arr) > 1: - await self.team_service.update_past_league_rewards(user_id) - return resp async def handle_update_time_trial_result_request( diff --git a/titles/idac/service/season3/team_service.py b/titles/idac/service/season3/team_service.py index a96c659..ca5ccae 100644 --- a/titles/idac/service/season3/team_service.py +++ b/titles/idac/service/season3/team_service.py @@ -1119,16 +1119,14 @@ class IDACSeason3TeamService: # user already claimed the league rewards return user_league_info_dto.rewards_claimed - async def update_past_league_rewards(self, user_id: int) -> bool: + async def update_past_league_rewards(self, user_id: int, team_id: int) -> bool: if not self.last_round_id: return False - team_member_dto = await self.get_team_member_dto(user_id) - await self.data.team.put_user_league_info( UserLeagueInfoDto( user=user_id, - team_id=team_member_dto.team_id, + team_id=team_id, round_id=self.last_round_id, rewards_claimed=True, )