James McCool commited on
Commit
be5801a
·
1 Parent(s): ff8afcc

Enhance utilization report data update functionality in app.py. Added user information for the update button, improved feedback messages for uploading player feed, current season, and team styles, and included error handling for current season updates.

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -767,10 +767,11 @@ with tab5:
767
  with tab6:
768
  with st.container():
769
  st.header("Update Utilization Report Data")
 
770
  if st.button("Update Scores", key='scores'):
771
  response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/scores/2025", headers=headers)
772
  if response.status_code == 200:
773
- st.write("Uploading!")
774
  st.write(response.json())
775
  st.cache_data.clear()
776
  for key in st.session_state.keys():
@@ -786,7 +787,23 @@ with tab6:
786
 
787
  response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/current-season/update", headers=headers)
788
  if response.status_code == 200:
789
- st.write("Uploading!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  st.write(response.json())
791
  st.cache_data.clear()
792
  for key in st.session_state.keys():
 
767
  with tab6:
768
  with st.container():
769
  st.header("Update Utilization Report Data")
770
+ st.info("Hitting this button will update all UR data (player, season, team styles) across the site")
771
  if st.button("Update Scores", key='scores'):
772
  response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/scores/2025", headers=headers)
773
  if response.status_code == 200:
774
+ st.write("Uploading Player Feed!")
775
  st.write(response.json())
776
  st.cache_data.clear()
777
  for key in st.session_state.keys():
 
787
 
788
  response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/current-season/update", headers=headers)
789
  if response.status_code == 200:
790
+ st.write("Uploading Current Season!")
791
+ st.write(response.json())
792
+ st.cache_data.clear()
793
+ for key in st.session_state.keys():
794
+ del st.session_state[key]
795
+ else:
796
+ st.write("Error updating current season")
797
+ st.write(response.json())
798
+ st.cache_data.clear()
799
+ for key in st.session_state.keys():
800
+ del st.session_state[key]
801
+
802
+ time.sleep(3)
803
+
804
+ response = requests.post(f"https://api.fantasylife.com/api/ur-team-styles/v1/current-season/update", headers=headers)
805
+ if response.status_code == 200:
806
+ st.write("Uploading Team Styles!")
807
  st.write(response.json())
808
  st.cache_data.clear()
809
  for key in st.session_state.keys():