James McCool commited on
Commit
7de18e9
·
1 Parent(s): 0690ce0

Update contest data retrieval in app.py to include current information

Browse files

- Modified the grab_contest_names function to return additional current information, enhancing data accessibility.
- Adjusted the contest selection logic to utilize the updated data structure, improving user experience during contest data loading.
- These changes contribute to ongoing efforts to streamline data handling and improve the overall functionality of the application.

Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -25,10 +25,9 @@ def grab_contest_names(db, sport):
25
  contest_id_map = dict(zip(curr_info['Contest Name'], curr_info['Contest ID']))
26
  contest_date_map = dict(zip(curr_info['Contest Name'], curr_info['Date']))
27
 
28
- return contest_names, contest_id_map, contest_date_map
29
 
30
  db = init_conn()
31
- contest_names, contest_id_map, contest_date_map = grab_contest_names(db, 'MLB')
32
 
33
  ## import global functions
34
  from global_func.load_contest_file import load_contest_file
@@ -56,22 +55,23 @@ with tab1:
56
  with col1:
57
  parse_type = st.selectbox("Manual upload or DB search?", ['DB Search', 'Manual'], key='parse_type')
58
  with col2:
59
- date_select = st.selectbox("Select Date", contest_date_map.values(), key='date_select')
60
- with col3:
61
  sport_select = st.selectbox("Select Sport", ['MLB', 'NBA', 'NFL'], key='sport_select')
 
 
 
62
  with col4:
63
  type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
64
  # Add file uploaders to your app
65
  col1, col2 = st.columns(2)
66
-
67
  with col1:
68
  st.subheader("Contest File")
69
  st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
70
  if parse_type == 'DB Search':
71
- contest_name_var = st.selectbox("Select Contest to load", contest_names)
72
  if 'Contest_file' not in st.session_state:
73
  if st.button('Load Contest Data', key='load_contest_data'):
74
- st.session_state['Contest_file'] = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
75
  else:
76
  pass
77
  elif parse_type == 'Manual':
 
25
  contest_id_map = dict(zip(curr_info['Contest Name'], curr_info['Contest ID']))
26
  contest_date_map = dict(zip(curr_info['Contest Name'], curr_info['Date']))
27
 
28
+ return contest_names, contest_id_map, contest_date_map, curr_info
29
 
30
  db = init_conn()
 
31
 
32
  ## import global functions
33
  from global_func.load_contest_file import load_contest_file
 
55
  with col1:
56
  parse_type = st.selectbox("Manual upload or DB search?", ['DB Search', 'Manual'], key='parse_type')
57
  with col2:
 
 
58
  sport_select = st.selectbox("Select Sport", ['MLB', 'NBA', 'NFL'], key='sport_select')
59
+ contest_names, contest_id_map, contest_date_map, curr_info = grab_contest_names(db, sport_select)
60
+ with col3:
61
+ date_select = st.selectbox("Select Date", contest_date_map.values(), key='date_select')
62
  with col4:
63
  type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
64
  # Add file uploaders to your app
65
  col1, col2 = st.columns(2)
66
+
67
  with col1:
68
  st.subheader("Contest File")
69
  st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
70
  if parse_type == 'DB Search':
71
+ contest_name_var = st.selectbox("Select Contest to load", curr_info[curr_info['Date'] == date_select]['Contest Name'])
72
  if 'Contest_file' not in st.session_state:
73
  if st.button('Load Contest Data', key='load_contest_data'):
74
+ st.session_state['Contest_file'] = grab_contest_data(sport_select, contest_name_var, contest_id_map, contest_date_map)
75
  else:
76
  pass
77
  elif parse_type == 'Manual':