

def get_page(self, user, max_page_size, is_above, score, score_time):
    self._read_leaderboard()
    scores = self.scores
    leaderboard = []
    player = None
    query_complete = False
    if (not is_above):
        scores = reversed(scores)
    for s in scores:
        if is_above:
            if (((self.sort_by * s.score) < (self.sort_by * score)) or ((s.score == score) and (s.score_time >= score_time))):
                query_complete = True
        elif (((self.sort_by * s.score) > (self.sort_by * score)) or ((s.score == score) and (s.score_time <= score_time))):
            query_complete = True
        if (query_complete and (len(leaderboard) >= max_page_size)):
            break
        username = s.user
        row = self._get_row(username, s)
        if (username == user.username):
            player = row
        leaderboard.append(row)
    leaderboard = leaderboard[(- max_page_size):]
    if (not is_above):
        leaderboard = list(reversed(leaderboard))
    if (player is None):
        player = self._get_user_row(user)
    if (len(leaderboard) > 0):
        self._rank_leaderboard(leaderboard, self._get_rank(leaderboard[0]['score']))
        top = (self.scores[0].user == leaderboard[0]['user']['username'])
        bottom = (self.scores[(- 1)].user == leaderboard[(- 1)]['user']['username'])
    else:
        top = True
        bottom = True
    return self.create_response(top, bottom, leaderboard, player)

dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/models/apiv1/leaderboards.py Leaderboard.get_page/original