Spaces:
Running
Running
James McCool
commited on
Commit
·
ff8afcc
1
Parent(s):
e5b862e
Add UR Push tab in app.py for updating utilization report data. Implemented functionality to update scores and current season data via API, including error handling and session state management.
Browse files
app.py
CHANGED
|
@@ -153,7 +153,7 @@ def grab_sr_ids(headers: dict) -> pd.DataFrame:
|
|
| 153 |
|
| 154 |
return pd.DataFrame(row_data, columns=['FA_ID', 'SR_ID', 'First_Name', 'Prefer_First_Name', 'Last_Name', 'Name_Suffix', 'Position', 'Team'])
|
| 155 |
|
| 156 |
-
tab1, tab2, tab3, tab4, tab5 = st.tabs(['Rankings Update', 'Projections Update', 'SR ID Update', 'Game Model Update', 'NCAAF Script'])
|
| 157 |
|
| 158 |
with tab1:
|
| 159 |
with st.container():
|
|
@@ -762,4 +762,38 @@ with tab5:
|
|
| 762 |
worksheet.update([export_df.columns.values.tolist()] + export_df.values.tolist())
|
| 763 |
st.write("Uploaded Master Schedule")
|
| 764 |
|
| 765 |
-
st.write("Finished NCAAF Script!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
return pd.DataFrame(row_data, columns=['FA_ID', 'SR_ID', 'First_Name', 'Prefer_First_Name', 'Last_Name', 'Name_Suffix', 'Position', 'Team'])
|
| 155 |
|
| 156 |
+
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(['Rankings Update', 'Projections Update', 'SR ID Update', 'Game Model Update', 'NCAAF Script', 'UR Push'])
|
| 157 |
|
| 158 |
with tab1:
|
| 159 |
with st.container():
|
|
|
|
| 762 |
worksheet.update([export_df.columns.values.tolist()] + export_df.values.tolist())
|
| 763 |
st.write("Uploaded Master Schedule")
|
| 764 |
|
| 765 |
+
st.write("Finished NCAAF Script!")
|
| 766 |
+
|
| 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():
|
| 777 |
+
del st.session_state[key]
|
| 778 |
+
else:
|
| 779 |
+
st.write("Error updating scores")
|
| 780 |
+
st.write(response.json())
|
| 781 |
+
st.cache_data.clear()
|
| 782 |
+
for key in st.session_state.keys():
|
| 783 |
+
del st.session_state[key]
|
| 784 |
+
|
| 785 |
+
time.sleep(3)
|
| 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():
|
| 793 |
+
del st.session_state[key]
|
| 794 |
+
else:
|
| 795 |
+
st.write("Error updating current season")
|
| 796 |
+
st.write(response.json())
|
| 797 |
+
st.cache_data.clear()
|
| 798 |
+
for key in st.session_state.keys():
|
| 799 |
+
del st.session_state[key]
|