James McCool commited on
Commit
8a794d7
·
1 Parent(s): d481fdb

Refactor rankings and projections update sections in app.py to improve organization and user experience. Added separate containers for regular and guillotine rankings, along with enhanced functionality for updating rest of season guillotine rankings. Updated layout for projections to streamline user interactions.

Browse files
Files changed (1) hide show
  1. app.py +35 -10
app.py CHANGED
@@ -157,9 +157,10 @@ tab1, tab2, tab3, tab4, tab5 = st.tabs(['Rankings Update', 'Projections Update',
157
 
158
  with tab1:
159
  with st.container():
160
- col1, col2, col3, col4, col5 = st.columns([3, 3, 3, 3, 3])
 
161
 
162
- with col1:
163
  st.info("Update Seasonal Rankings")
164
  choose_seasonal_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_ranker')
165
  choose_seasonal_ranker = api_replace_options[name_options.index(choose_seasonal_ranker)]
@@ -178,7 +179,7 @@ with tab1:
178
  for key in st.session_state.keys():
179
  del st.session_state[key]
180
 
181
- with col2:
182
  st.info("Update Rest of Season Rankings")
183
  choose_ros_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_ranker')
184
  choose_ros_ranker = api_replace_options[name_options.index(choose_ros_ranker)]
@@ -197,7 +198,7 @@ with tab1:
197
  for key in st.session_state.keys():
198
  del st.session_state[key]
199
 
200
- with col3:
201
  st.info("Update Weekly Rankings")
202
  choose_weekly_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_ranker')
203
  choose_weekly_ranker = api_replace_options[name_options.index(choose_weekly_ranker)]
@@ -215,8 +216,12 @@ with tab1:
215
  st.cache_data.clear()
216
  for key in st.session_state.keys():
217
  del st.session_state[key]
 
 
 
 
218
 
219
- with col4:
220
  st.info("Update Seasonal Guillotine Rankings")
221
  choose_seasonal_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_guillotine_ranker')
222
  choose_seasonal_guillotine_ranker = api_replace_options[name_options.index(choose_seasonal_guillotine_ranker)]
@@ -235,7 +240,26 @@ with tab1:
235
  for key in st.session_state.keys():
236
  del st.session_state[key]
237
 
238
- with col5:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  st.info("Update Weekly Guillotine Rankings")
240
  choose_weekly_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_guillotine_ranker')
241
  choose_weekly_guillotine_ranker = api_replace_options[name_options.index(choose_weekly_guillotine_ranker)]
@@ -258,9 +282,10 @@ with tab1:
258
 
259
  with tab2:
260
  with st.container():
261
- col1, col2, col3, col4 = st.columns([3, 3, 3, 3])
 
262
 
263
- with col1:
264
  st.info("Update Seasonal Projections")
265
  choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
266
  choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
@@ -287,7 +312,7 @@ with tab2:
287
  st.cache_data.clear()
288
  for key in st.session_state.keys():
289
  del st.session_state[key]
290
- with col2:
291
  st.info("Update Weekly Projections")
292
  choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
293
  choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
@@ -315,7 +340,7 @@ with tab2:
315
  for key in st.session_state.keys():
316
  del st.session_state[key]
317
 
318
- with col3:
319
  st.info("Update Rest of Season Projections")
320
  choose_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_type')
321
  choose_ros_type = ros_replace_options[ros_source_options.index(choose_ros_type)]
 
157
 
158
  with tab1:
159
  with st.container():
160
+ st.header("Update Regular Rankings")
161
+ reg_seasonal_col, reg_ros_col, reg_weekly_col = st.columns([3, 3, 3])
162
 
163
+ with reg_seasonal_col:
164
  st.info("Update Seasonal Rankings")
165
  choose_seasonal_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_ranker')
166
  choose_seasonal_ranker = api_replace_options[name_options.index(choose_seasonal_ranker)]
 
179
  for key in st.session_state.keys():
180
  del st.session_state[key]
181
 
182
+ with reg_ros_col:
183
  st.info("Update Rest of Season Rankings")
184
  choose_ros_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_ranker')
185
  choose_ros_ranker = api_replace_options[name_options.index(choose_ros_ranker)]
 
198
  for key in st.session_state.keys():
199
  del st.session_state[key]
200
 
201
+ with reg_weekly_col:
202
  st.info("Update Weekly Rankings")
203
  choose_weekly_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_ranker')
204
  choose_weekly_ranker = api_replace_options[name_options.index(choose_weekly_ranker)]
 
216
  st.cache_data.clear()
217
  for key in st.session_state.keys():
218
  del st.session_state[key]
219
+
220
+ with st.container():
221
+ st.header("Update Guillotine Rankings")
222
+ guillotine_seasonal_col, guillotine_ros_col, guillotine_weekly_col = st.columns([3, 3, 3])
223
 
224
+ with guillotine_seasonal_col:
225
  st.info("Update Seasonal Guillotine Rankings")
226
  choose_seasonal_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_guillotine_ranker')
227
  choose_seasonal_guillotine_ranker = api_replace_options[name_options.index(choose_seasonal_guillotine_ranker)]
 
240
  for key in st.session_state.keys():
241
  del st.session_state[key]
242
 
243
+ with guillotine_ros_col:
244
+ st.info("Update Rest of Season Guillotine Rankings")
245
+ choose_rest_of_season_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_guillotine_ranker')
246
+ choose_rest_of_season_guillotine_ranker = api_replace_options[name_options.index(choose_rest_of_season_guillotine_ranker)]
247
+ if st.button("Update Rest of Season Guillotine Rankings", key='rest_of_season_guillotine_rankings'):
248
+ response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_rest_of_season_guillotine_ranker}/season/update", headers=headers)
249
+ if response.status_code == 200:
250
+ st.write("Uploading!")
251
+ st.write(response.json())
252
+ st.cache_data.clear()
253
+ for key in st.session_state.keys():
254
+ del st.session_state[key]
255
+ else:
256
+ st.write("Error uploading rest of season guillotine rankings")
257
+ st.write(response.json())
258
+ st.cache_data.clear()
259
+ for key in st.session_state.keys():
260
+ del st.session_state[key]
261
+
262
+ with guillotine_weekly_col:
263
  st.info("Update Weekly Guillotine Rankings")
264
  choose_weekly_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_guillotine_ranker')
265
  choose_weekly_guillotine_ranker = api_replace_options[name_options.index(choose_weekly_guillotine_ranker)]
 
282
 
283
  with tab2:
284
  with st.container():
285
+ st.header("Update Regular Projections")
286
+ reg_seasonal_proj_col, reg_ros_proj_col, reg_weekly_proj_col = st.columns([3, 3, 3])
287
 
288
+ with reg_seasonal_proj_col:
289
  st.info("Update Seasonal Projections")
290
  choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
291
  choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
 
312
  st.cache_data.clear()
313
  for key in st.session_state.keys():
314
  del st.session_state[key]
315
+ with reg_weekly_proj_col:
316
  st.info("Update Weekly Projections")
317
  choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
318
  choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
 
340
  for key in st.session_state.keys():
341
  del st.session_state[key]
342
 
343
+ with reg_ros_proj_col:
344
  st.info("Update Rest of Season Projections")
345
  choose_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_type')
346
  choose_ros_type = ros_replace_options[ros_source_options.index(choose_ros_type)]