'Returns leaderboards with ranking for the past given days.
This will return a dict of 3 items::
{\'leader_top\': [...],
\'leader_near: [...],
\'user_rank\': (int)}
If the user is not in the leaderboard, or if the user is in the top 5,
\'leader_near\' will be an empty list and \'leader_top\' will contain 5
elements instead of the normal 3.'

@classmethod
def get_leaderboards(cls, user, days=7, types=None):

    key = cls.get_key(('get_leaderboards:%s' % user.id))
    val = cache.get(key)
    if (val is not None):
        return val
    week_ago = (datetime.date.today() - datetime.timedelta(days=days))
    leader_top = []
    leader_near = []
    query = cls._leaderboard_query(since=week_ago, types=types)
    scores = []
    user_rank = 0
    in_leaderboard = False
    for (rank, row) in enumerate(query, 1):
        (user_id, name, total) = row
        scores.append({'user_id': user_id, 'name': name, 'rank': rank, 'total': int(total)})
        if (user_id == user.id):
            user_rank = rank
            in_leaderboard = True
    if (not in_leaderboard):
        leader_top = scores[:5]
    elif (user_rank <= 5):
        leader_top = scores[:5]
    else:
        leader_top = scores[:3]
        leader_near = [scores[(user_rank - 2)], scores[(user_rank - 1)]]
        try:
            leader_near.append(scores[user_rank])
        except IndexError:
            pass
    val = {'leader_top': leader_top, 'leader_near': leader_near, 'user_rank': user_rank}
    cache.set(key, val, None)
    return val
