James McCool
commited on
Commit
·
d80e5ce
1
Parent(s):
c880551
Enhance data loading functionality by introducing a flag to track portfolio loading status. This allows for better handling of session state when loading from Paydirt DB, ensuring the portfolio is correctly managed in the session.
Browse files
app.py
CHANGED
|
@@ -560,11 +560,13 @@ if selected_tab == 'Data Load':
|
|
| 560 |
st.info("Go ahead and upload a portfolio file here. Only include player columns.")
|
| 561 |
|
| 562 |
upload_toggle = st.selectbox("What source are you uploading from?", options=['Paydirt DB', 'SaberSim (Just IDs)', 'Draftkings/Fanduel (Names + IDs)', 'Other (Just Names)'])
|
|
|
|
| 563 |
if upload_toggle == 'Paydirt DB':
|
| 564 |
if st.button("Load from Database after inserting site CSV"):
|
| 565 |
if site_var == 'Draftkings':
|
| 566 |
portfolio_load = init_DK_NFL_lineups(type_var, 'Main', 'proj', 50, dk_nfl_showdown_db_translation, 1000, [])
|
| 567 |
portfolio_file = pd.DataFrame(portfolio_load)
|
|
|
|
| 568 |
if 'portfolio' in st.session_state:
|
| 569 |
del st.session_state['portfolio']
|
| 570 |
if 'export_portfolio' in st.session_state:
|
|
@@ -572,6 +574,7 @@ if selected_tab == 'Data Load':
|
|
| 572 |
else:
|
| 573 |
portfolio_load = init_FD_NFL_lineups(type_var, 'Main', 'proj', 50, fd_nfl_showdown_db_translation, 1000, [])
|
| 574 |
portfolio_file = pd.DataFrame(portfolio_load)
|
|
|
|
| 575 |
if 'portfolio' in st.session_state:
|
| 576 |
del st.session_state['portfolio']
|
| 577 |
if 'export_portfolio' in st.session_state:
|
|
@@ -592,7 +595,7 @@ if selected_tab == 'Data Load':
|
|
| 592 |
del st.session_state['export_portfolio']
|
| 593 |
|
| 594 |
if 'portfolio' not in st.session_state:
|
| 595 |
-
if portfolio_file:
|
| 596 |
if upload_toggle == 'Paydirt DB':
|
| 597 |
st.session_state['export_portfolio'] = portfolio_file
|
| 598 |
st.session_state['portfolio'] = portfolio_file
|
|
@@ -612,7 +615,7 @@ if selected_tab == 'Data Load':
|
|
| 612 |
|
| 613 |
st.session_state['portfolio'] = st.session_state['portfolio'].dropna(how='all')
|
| 614 |
st.session_state['portfolio'] = st.session_state['portfolio'].reset_index(drop=True)
|
| 615 |
-
|
| 616 |
else:
|
| 617 |
st.session_state['export_portfolio'], st.session_state['portfolio'] = load_file(portfolio_file, site_var, type_var, sport_var, 'portfolio')
|
| 618 |
st.session_state['export_portfolio'] = st.session_state['export_portfolio'].dropna(how='all')
|
|
|
|
| 560 |
st.info("Go ahead and upload a portfolio file here. Only include player columns.")
|
| 561 |
|
| 562 |
upload_toggle = st.selectbox("What source are you uploading from?", options=['Paydirt DB', 'SaberSim (Just IDs)', 'Draftkings/Fanduel (Names + IDs)', 'Other (Just Names)'])
|
| 563 |
+
portfolio_loaded = False
|
| 564 |
if upload_toggle == 'Paydirt DB':
|
| 565 |
if st.button("Load from Database after inserting site CSV"):
|
| 566 |
if site_var == 'Draftkings':
|
| 567 |
portfolio_load = init_DK_NFL_lineups(type_var, 'Main', 'proj', 50, dk_nfl_showdown_db_translation, 1000, [])
|
| 568 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 569 |
+
portfolio_loaded = True
|
| 570 |
if 'portfolio' in st.session_state:
|
| 571 |
del st.session_state['portfolio']
|
| 572 |
if 'export_portfolio' in st.session_state:
|
|
|
|
| 574 |
else:
|
| 575 |
portfolio_load = init_FD_NFL_lineups(type_var, 'Main', 'proj', 50, fd_nfl_showdown_db_translation, 1000, [])
|
| 576 |
portfolio_file = pd.DataFrame(portfolio_load)
|
| 577 |
+
portfolio_loaded = True
|
| 578 |
if 'portfolio' in st.session_state:
|
| 579 |
del st.session_state['portfolio']
|
| 580 |
if 'export_portfolio' in st.session_state:
|
|
|
|
| 595 |
del st.session_state['export_portfolio']
|
| 596 |
|
| 597 |
if 'portfolio' not in st.session_state:
|
| 598 |
+
if portfolio_file or portfolio_loaded:
|
| 599 |
if upload_toggle == 'Paydirt DB':
|
| 600 |
st.session_state['export_portfolio'] = portfolio_file
|
| 601 |
st.session_state['portfolio'] = portfolio_file
|
|
|
|
| 615 |
|
| 616 |
st.session_state['portfolio'] = st.session_state['portfolio'].dropna(how='all')
|
| 617 |
st.session_state['portfolio'] = st.session_state['portfolio'].reset_index(drop=True)
|
| 618 |
+
|
| 619 |
else:
|
| 620 |
st.session_state['export_portfolio'], st.session_state['portfolio'] = load_file(portfolio_file, site_var, type_var, sport_var, 'portfolio')
|
| 621 |
st.session_state['export_portfolio'] = st.session_state['export_portfolio'].dropna(how='all')
|