Beispiel #1
0
def line1():
    ''' Player B1 (second pick).'''

    con = pi.open_sql_con()

    # Update the lineup by insterting the selected player on the previous page into the lineup table
    id_1a = request.form.get('first_pick')
    (player_1a, player_1a_id) = an.get_prev_player(con, id_1a, 'team_a')
    an.update_lineup(con,
                     player_1a,
                     player_1a_id,
                     0,
                     poss=[1, 2, 3, 4, 5, 6, 7, 8, 9])

    # Load team and current lineup data
    team_B_df = an.load_team_b(con)
    lineup = an.get_lineup(con)

    # Update analytics for visualization
    pj = an.agg_scores_init(con)
    cj = an.agg_coefs_init(con)
    plot_url = an.print_figure_init(pj, cj)

    con.close()

    return render_template('line1.html',
                           teamb=team_B_df,
                           lineup=lineup,
                           plot_url=plot_url)
Beispiel #2
0
def pick1():
    ''' Player A1 (first pick).'''

    con = pi.open_sql_con()

    # Clear the lineup to prevent caching issues
    an.clear_lineup(con)

    # Load team data and identify the suggested player
    team_A_df = an.load_team_a(con)
    team_B_df = an.load_team_b(con)
    stds = an.calc_stds_coef(con, team_A_df, team_B_df)
    rec = [''] * len(team_A_df)
    rec[0] = ' (Recommended)'

    # Update analytics for visualization
    pj = an.agg_scores_init(con)
    cj = an.agg_coefs_init(con)
    plot_url = an.print_figure_init(pj, cj)

    con.close()

    return render_template('pick1.html',
                           teams1=stds,
                           rec=rec,
                           plot_url=plot_url)
Beispiel #3
0
def line5():
    ''' Player B5 (second pick).'''

    con = pi.open_sql_con()

    # Update the lineup by inserting the selected player on the previous page into the lineup table
    an.add_prev_player(con,
                       form='fifth_pick',
                       team='team_a',
                       prev_pos=8,
                       poss=[9])
    # Retrieve the current lineup, available team B players, and the updated visualization
    (lineup, team_B_df, plot_url) = an.b_pick(con)

    con.close()

    return render_template('line5.html',
                           teamb=team_B_df,
                           lineup=lineup,
                           plot_url=plot_url)
Beispiel #4
0
def pick5():
    ''' Player A5 (first pick).'''

    con = pi.open_sql_con()

    # Update the lineup by insterting the selected player on the previous page into the lineup table
    an.add_prev_player(con,
                       form='fourth_pick',
                       team='team_a',
                       prev_pos=6,
                       poss=[8, 9])
    # Retrieve the current lineup, available team A players, the recommended player selection, and the updated visualization
    (lineup, team_A_df, rec, plot_url) = an.a_pick_first(con)

    con.close()

    return render_template('pick5.html',
                           teams5=team_A_df,
                           rec=rec,
                           lineup=lineup,
                           plot_url=plot_url)
Beispiel #5
0
def pick4():
    ''' Player A4 (second pick).'''

    con = pi.open_sql_con()

    # Update the lineup by insterting the selected player on the previous page into the lineup table
    (player_4b, player_4b_id) = an.add_prev_player(con,
                                                   form='fourth_pick',
                                                   team='team_b',
                                                   prev_pos=7,
                                                   poss=[6, 8, 9])
    # Retrieve the current lineup, available team A players, the recommended player selection, and the updated visualization
    (lineup, team_A_df, rec,
     plot_url) = an.a_pick_second(con, player_4b, player_4b_id)

    con.close()

    return render_template('pick4.html',
                           options=team_A_df,
                           rec=rec,
                           lineup=lineup,
                           plot_url=plot_url)
Beispiel #6
0
def summary():
    ''' Produce summary statistics for this permutation to see how well it compares to random selections.'''

    con = pi.open_sql_con()

    # Update the lineup by insterting the selected player on the previous page into the lineup table
    an.add_prev_player(con,
                       form='fifth_pick',
                       team='team_b',
                       prev_pos=9,
                       poss=[])
    # Retrieve the final lineup and summary statistics
    (final, tot_perms, perm_coef, av_coef, rank,
     plot_url) = an.create_summary(con)

    con.close()

    return render_template('summary.html',
                           final=final,
                           tot_perms=tot_perms,
                           perm_coef=perm_coef,
                           av_coef=av_coef,
                           rank=rank,
                           plot_url=plot_url)