def set(self, user, new_score):
        score_time = time_now()

        self._read_leaderboard()
        try:
            users_score = self.user_scores[user.username]
            old_score = users_score.score

            if (self.sort_by == 1 and old_score >= new_score) or (self.sort_by == -1 and old_score <= new_score):
                return {'bestScore': old_score}

            users_score.score = new_score
            users_score.score_time = score_time

            if self.aggregate:
                self.aggregate_score += new_score - old_score
            self._write_leaderboard()
            return {'newBest': True, 'prevBest': old_score}
        except KeyError:
            # User has no score on the leaderboard
            self._add_score(UserScore(user.username, new_score, score_time))
            self._write_leaderboard()
            return {'newBest': True}
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/models/apiv1/leaderboards.py/Leaderboard.set/original