Exemplo n.º 1
0
Arquivo: web.py Projeto: sharan1/love
def leaderboard():
    timespan = request.args.get('timespan', TIMESPAN_THIS_WEEK)
    department = request.args.get('department', None)

    (top_lover_dicts, top_loved_dicts) = get_leaderboard_data(timespan, department)

    return render_template(
        'leaderboard.html',
        top_loved=top_loved_dicts,
        top_lovers=top_lover_dicts,
        departments=logic.department.META_DEPARTMENTS,
        sub_departments=logic.department.META_DEPARTMENT_MAP,
        selected_dept=department,
        selected_timespan=timespan,
        org_title=config.ORG_TITLE,
    )
Exemplo n.º 2
0
Arquivo: api.py Projeto: sharan1/love
def api_get_leaderboard():
    department = request.args.get('department', None)
    timespan = request.args.get('timespan', TIMESPAN_THIS_WEEK)

    (top_lover_dicts,
     top_loved_dicts) = get_leaderboard_data(timespan, department)

    top_lover = [{
        'full_name': lover['employee'].full_name,
        'username': lover['employee'].username,
        'department': lover['employee'].department,
        'love_count': lover['num_sent'],
    } for lover in top_lover_dicts]

    top_loved = [{
        'full_name': loved['employee'].full_name,
        'username': loved['employee'].username,
        'department': loved['employee'].department,
        'love_count': loved['num_received'],
    } for loved in top_loved_dicts]
    final_result = {'top_loved': top_loved, 'top_lover': top_lover}
    return make_json_response(final_result)