Spaces:
Running
Running
James McCool commited on
Commit ·
88c69dd
1
Parent(s): 5242309
Refactor projection update logic in app.py to include aggregate updates for both seasonal and weekly projections, enhancing functionality and user feedback during API interactions.
Browse files
app.py
CHANGED
|
@@ -45,8 +45,8 @@ headers = {
|
|
| 45 |
}
|
| 46 |
|
| 47 |
name_options = ['Dwain', 'Freedman', 'Ian', 'Waz', 'Charch', 'Kendall', 'Sam', 'Matthew Berry']
|
| 48 |
-
proj_source_options = ['Dwain', '
|
| 49 |
-
proj_replace_options = ['dwain', '
|
| 50 |
api_replace_options = ['dwain', 'freedman', 'ian', 'waz', 'charch', 'kendall', 'sam', 'berry', 'james', 'james_ncaaf']
|
| 51 |
|
| 52 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
|
@@ -206,19 +206,25 @@ with tab2:
|
|
| 206 |
choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
|
| 207 |
choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
|
| 208 |
if st.button("Update Seasonal Projections", key='seasonal_projections'):
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
| 213 |
with col2:
|
| 214 |
st.info("Update Weekly Projections")
|
| 215 |
choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
|
| 216 |
choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
|
| 217 |
if st.button("Update Weekly Projections", key='weekly_projections'):
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
with tab3:
|
| 224 |
with st.container():
|
|
|
|
| 45 |
}
|
| 46 |
|
| 47 |
name_options = ['Dwain', 'Freedman', 'Ian', 'Waz', 'Charch', 'Kendall', 'Sam', 'Matthew Berry']
|
| 48 |
+
proj_source_options = ['Dwain', 'Freedman', 'Kickers', 'Defenses']
|
| 49 |
+
proj_replace_options = ['dwain', 'freedman', 'kickers', 'defenses']
|
| 50 |
api_replace_options = ['dwain', 'freedman', 'ian', 'waz', 'charch', 'kendall', 'sam', 'berry', 'james', 'james_ncaaf']
|
| 51 |
|
| 52 |
def grab_sr_fa(headers: dict) -> pd.DataFrame:
|
|
|
|
| 206 |
choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
|
| 207 |
choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
|
| 208 |
if st.button("Update Seasonal Projections", key='seasonal_projections'):
|
| 209 |
+
response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_seasonal_type}/seasonal/update", headers=headers)
|
| 210 |
+
if response.status_code == 200:
|
| 211 |
+
st.write("Uploading!")
|
| 212 |
+
st.write(response.json())
|
| 213 |
+
response = requests.post(f"https://api.fantasylife.com/api/projections/v1/aggregate/seasonal/update", headers=headers)
|
| 214 |
+
if response.status_code == 200:
|
| 215 |
+
st.write("Uploading Aggregate as well.")
|
| 216 |
with col2:
|
| 217 |
st.info("Update Weekly Projections")
|
| 218 |
choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
|
| 219 |
choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
|
| 220 |
if st.button("Update Weekly Projections", key='weekly_projections'):
|
| 221 |
+
response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_weekly_type}/weekly/update", headers=headers)
|
| 222 |
+
if response.status_code == 200:
|
| 223 |
+
st.write("Uploading!")
|
| 224 |
+
st.write(response.json())
|
| 225 |
+
response = requests.post(f"https://api.fantasylife.com/api/projections/v1/aggregate/weekly/update", headers=headers)
|
| 226 |
+
if response.status_code == 200:
|
| 227 |
+
st.write("Uploading Aggregate as well.")
|
| 228 |
|
| 229 |
with tab3:
|
| 230 |
with st.container():
|