James McCool
commited on
Commit
·
35472d1
1
Parent(s):
de7aa9f
Enhance contest data upload feedback in app.py
Browse files- Updated the export_contest_file function to return user feedback messages for both existing contest data and successful uploads, improving user experience.
- Modified the user interface to display these messages in a dedicated column, ensuring clear communication of the upload status.
app.py
CHANGED
@@ -64,8 +64,8 @@ def export_contest_file(db, sport, type, contest_date, contest_id, contest_data)
|
|
64 |
cursor = collection.find()
|
65 |
contest_import = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
66 |
if contest_id in contest_import['Contest ID'].values:
|
67 |
-
st.info("Data for this contest already exists, no need to upload, but we appreciate the effort!")
|
68 |
-
return
|
69 |
except:
|
70 |
contest_import = pd.DataFrame(columns = ['Rank', 'EntryId', 'EntryName', 'TimeRemaining', 'Points', 'Lineup', 'Player', 'Roster Position', '%Drafted', 'FPTS', 'Contest Date', 'Contest ID'])
|
71 |
|
@@ -83,8 +83,9 @@ def export_contest_file(db, sport, type, contest_date, contest_id, contest_data)
|
|
83 |
break
|
84 |
except Exception as e:
|
85 |
print(f"Retry due to error: {e}")
|
|
|
86 |
|
87 |
-
return
|
88 |
|
89 |
db = init_conn()
|
90 |
|
@@ -172,12 +173,14 @@ with tab1:
|
|
172 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
173 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
174 |
if st.session_state['Contest'] is not None:
|
175 |
-
success_col, blank_col, upload_col = st.columns([2, 1, 1])
|
176 |
with success_col:
|
177 |
st.success('Contest file loaded successfully!')
|
178 |
with upload_col:
|
179 |
if st.button('Send file to Database?', key='export_contest_file'):
|
180 |
-
export_contest_file(db, sport_select, type_var, date_select, contest_id_map[contest_name_var], st.session_state['Contest_file'])
|
|
|
|
|
181 |
st.dataframe(st.session_state['Contest'].head(100))
|
182 |
|
183 |
if 'Contest_file' in st.session_state:
|
|
|
64 |
cursor = collection.find()
|
65 |
contest_import = pd.DataFrame(list(cursor)).drop('_id', axis=1)
|
66 |
if contest_id in contest_import['Contest ID'].values:
|
67 |
+
return_message = st.info("Data for this contest already exists, no need to upload, but we appreciate the effort!")
|
68 |
+
return return_message
|
69 |
except:
|
70 |
contest_import = pd.DataFrame(columns = ['Rank', 'EntryId', 'EntryName', 'TimeRemaining', 'Points', 'Lineup', 'Player', 'Roster Position', '%Drafted', 'FPTS', 'Contest Date', 'Contest ID'])
|
71 |
|
|
|
83 |
break
|
84 |
except Exception as e:
|
85 |
print(f"Retry due to error: {e}")
|
86 |
+
return_message = st.success("Contest data uploaded successfully! We appreciate the data!")
|
87 |
|
88 |
+
return return_message
|
89 |
|
90 |
db = init_conn()
|
91 |
|
|
|
173 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
174 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
175 |
if st.session_state['Contest'] is not None:
|
176 |
+
success_col, blank_col, upload_col, message_col = st.columns([2, 1, 1, 1])
|
177 |
with success_col:
|
178 |
st.success('Contest file loaded successfully!')
|
179 |
with upload_col:
|
180 |
if st.button('Send file to Database?', key='export_contest_file'):
|
181 |
+
return_message = export_contest_file(db, sport_select, type_var, date_select, contest_id_map[contest_name_var], st.session_state['Contest_file'])
|
182 |
+
with message_col:
|
183 |
+
st.info(return_message)
|
184 |
st.dataframe(st.session_state['Contest'].head(100))
|
185 |
|
186 |
if 'Contest_file' in st.session_state:
|