James McCool
commited on
Commit
·
9cc55fb
1
Parent(s):
c1c18f8
Enhance contest data retrieval with secondary date handling
Browse files- Updated the grab_contest_data function to utilize a secondary date parameter for improved data retrieval reliability.
- Modified app.py to pass the additional date parameter, ensuring fallback options for contest data loading.
- Maintained existing functionality while enhancing the robustness of the data loading process.
- app.py +1 -1
- global_func/grab_contest_data.py +8 -8
app.py
CHANGED
|
@@ -92,7 +92,7 @@ with tab1:
|
|
| 92 |
if 'Contest_file' not in st.session_state:
|
| 93 |
st.session_state['Contest_upload'] = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 94 |
st.session_state['Contest_file'] = pd.read_csv(st.session_state['Contest_upload'])
|
| 95 |
-
st.session_state['Contest_file_helper'] = grab_contest_data(sport_select, contest_name_var, contest_id_map, date_select)
|
| 96 |
else:
|
| 97 |
pass
|
| 98 |
|
|
|
|
| 92 |
if 'Contest_file' not in st.session_state:
|
| 93 |
st.session_state['Contest_upload'] = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 94 |
st.session_state['Contest_file'] = pd.read_csv(st.session_state['Contest_upload'])
|
| 95 |
+
st.session_state['Contest_file_helper'] = grab_contest_data(sport_select, contest_name_var, contest_id_map, date_select, date_select2)
|
| 96 |
else:
|
| 97 |
pass
|
| 98 |
|
global_func/grab_contest_data.py
CHANGED
|
@@ -4,12 +4,8 @@ import requests
|
|
| 4 |
def grab_contest_data(sport, contest_name, contest_id_map, contest_date, contest_date2):
|
| 5 |
|
| 6 |
contest_id = contest_id_map[contest_name]
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
except:
|
| 10 |
-
raw_url = f'https://dh5nxc6yx3kwy.cloudfront.net/contests/{sport.lower()}/{contest_date2}/{contest_id}/'
|
| 11 |
-
data_url = raw_url + 'data/'
|
| 12 |
-
lineups_url = raw_url + 'lineups/'
|
| 13 |
|
| 14 |
def format_lineup_string(lineup_hash, positions):
|
| 15 |
"""Replaces colons in a lineup hash with sequential positions."""
|
|
@@ -39,8 +35,12 @@ def grab_contest_data(sport, contest_name, contest_id_map, contest_date, contest
|
|
| 39 |
# Join them into a single string
|
| 40 |
return "".join(combined_parts)
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
lineup_data = []
|
| 46 |
player_data = []
|
|
|
|
| 4 |
def grab_contest_data(sport, contest_name, contest_id_map, contest_date, contest_date2):
|
| 5 |
|
| 6 |
contest_id = contest_id_map[contest_name]
|
| 7 |
+
raw_url = f'https://dh5nxc6yx3kwy.cloudfront.net/contests/{sport.lower()}/{contest_date}/{contest_id}/'
|
| 8 |
+
raw_url2 = f'https://dh5nxc6yx3kwy.cloudfront.net/contests/{sport.lower()}/{contest_date2}/{contest_id}/'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def format_lineup_string(lineup_hash, positions):
|
| 11 |
"""Replaces colons in a lineup hash with sequential positions."""
|
|
|
|
| 35 |
# Join them into a single string
|
| 36 |
return "".join(combined_parts)
|
| 37 |
|
| 38 |
+
try:
|
| 39 |
+
lineups_json = requests.get(raw_url + 'lineups/').json()
|
| 40 |
+
data_json = requests.get(raw_url + 'data/').json()
|
| 41 |
+
except:
|
| 42 |
+
lineups_json = requests.get(raw_url2 + 'lineups/').json()
|
| 43 |
+
data_json = requests.get(raw_url2 + 'data/').json()
|
| 44 |
|
| 45 |
lineup_data = []
|
| 46 |
player_data = []
|