James McCool commited on
Commit
2fef8c4
·
1 Parent(s): 1549530

Enhance Gamelogs filtering with player toggle and improved display logic

Browse files

Modify the Gamelogs tab to:
- Add a toggle for viewing all players or a specific player
- Refactor filtering logic to support both single player and all player views
- Create a separate 'gamelogs_final' session state for filtered results
- Maintain existing gradient styling and display formatting

Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -790,18 +790,26 @@ with tab4:
790
  if 'gamelogs_display' in st.session_state:
791
  st.subheader("Gamelogs")
792
  with st.container():
793
- col1, col2 = st.columns([4, 4])
794
- with col1:
795
- player_search = st.selectbox("Search for a player", st.session_state.gamelogs_display['Player'].unique().tolist())
796
  with col2:
797
- scenario_search = st.selectbox("Wins, Losses, or All games?", ['Wins', 'Losses', 'All'])
 
 
 
 
 
 
 
798
 
799
- st.session_state.gamelogs_display = st.session_state.gamelogs_display[st.session_state.gamelogs_display['Player'] == player_search]
 
 
 
800
  if scenario_search == 'Wins':
801
- st.session_state.gamelogs_display = st.session_state.gamelogs_display[st.session_state.gamelogs_display['W/L'] == 1]
802
  elif scenario_search == 'Losses':
803
- st.session_state.gamelogs_display = st.session_state.gamelogs_display[st.session_state.gamelogs_display['W/L'] == 0]
804
  else:
805
- st.session_state.gamelogs_display = st.session_state.gamelogs_display
806
 
807
- st.dataframe(st.session_state.gamelogs_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
 
790
  if 'gamelogs_display' in st.session_state:
791
  st.subheader("Gamelogs")
792
  with st.container():
793
+ col1, col2, col3 = st.columns([4, 4, 4])
 
 
794
  with col2:
795
+ player_toggle = st.selectbox("Do you want to view all players or just one?", ['All', 'One'])
796
+ with col2:
797
+ if player_toggle == 'One':
798
+ player_search = st.selectbox("Search for a player", st.session_state.gamelogs_display['Player'].unique().tolist())
799
+ else:
800
+ player_search = 'All'
801
+ with col3:
802
+ scenario_search = st.selectbox("Wins, Losses, or All games?", ['All', 'Wins', 'Losses'])
803
 
804
+ if player_toggle == 'One':
805
+ st.session_state.gamelogs_final = st.session_state.gamelogs_display[st.session_state.gamelogs_display['Player'] == player_search]
806
+ else:
807
+ st.session_state.gamelogs_final = st.session_state.gamelogs_display
808
  if scenario_search == 'Wins':
809
+ st.session_state.gamelogs_final = st.session_state.gamelogs_final[st.session_state.gamelogs_final['W/L'] == 1]
810
  elif scenario_search == 'Losses':
811
+ st.session_state.gamelogs_final = st.session_state.gamelogs_final[st.session_state.gamelogs_final['W/L'] == 0]
812
  else:
813
+ st.session_state.gamelogs_final = st.session_state.gamelogs_final
814
 
815
+ st.dataframe(st.session_state.gamelogs_final.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)