示例#1
0
文件: http.py 项目: noise/leaders-py
def leaders(game, metric, range_code):
    for r in Leaderboard.RANGES_ALL:
        if r.range_code == range_code:
            range = r
            break

    b = Leaderboard(game, metric, r)
    l = b.leaders(r)
    return json.dumps(l)
示例#2
0
文件: http.py 项目: noise/leaders-py
def add_value(game, metric, user):
    try:
        value = request.values['value']
    except(KeyError):
        return ('Must provide "value" parameter', 400)
    
    # TODO: figure out how we should deal with spec'ing time ranges for the board?
    # TODO: just punt for now and use all ranges?
    b = Leaderboard(game, metric, Leaderboard.RANGES_ALL)
    b.set_metric(user, value)
    return "OK"