Spaces:
Sleeping
Sleeping
Jon Solow
commited on
Commit
·
3639273
1
Parent(s):
c30e41f
Set filters in mrs by url parameter
Browse files
src/pages/80_Maximum_Roster_Strategy.py
CHANGED
@@ -126,10 +126,30 @@ Pick up a player during their game's time slot for potential upside if particula
|
|
126 |
After the game, players will be colored by outcome: Drop (Red), Light Hold (Yellow), or Strong Hold (Green)."""
|
127 |
)
|
128 |
col_select, week_select = st.columns(2, gap="small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
with col_select:
|
130 |
-
position = st.selectbox(label="Position", options=POSITION_OPTIONS, index=
|
131 |
with week_select:
|
132 |
-
week = st.selectbox(label="Week", options=
|
|
|
|
|
133 |
if st.experimental_get_query_params().get("refresh"):
|
134 |
st.cache_data.clear()
|
135 |
df_mrs, all_time_slots_df = load_data()
|
|
|
126 |
After the game, players will be colored by outcome: Drop (Red), Light Hold (Yellow), or Strong Hold (Green)."""
|
127 |
)
|
128 |
col_select, week_select = st.columns(2, gap="small")
|
129 |
+
url_params = st.experimental_get_query_params()
|
130 |
+
initial_position_index = 0
|
131 |
+
if url_position := url_params.get("position"):
|
132 |
+
selected_position = url_position[0]
|
133 |
+
if selected_position in POSITION_OPTIONS:
|
134 |
+
initial_position_index = POSITION_OPTIONS.index(selected_position)
|
135 |
+
|
136 |
+
week_options = list(range(MAXIMUM_WEEK, MINIMUM_WEEK - 1, -1))
|
137 |
+
initial_week_index = 0
|
138 |
+
if url_week := url_params.get("week"):
|
139 |
+
try:
|
140 |
+
selected_week = int(url_week[0])
|
141 |
+
except Exception:
|
142 |
+
st.warning("Week parameter must be integer value", icon="⚠️")
|
143 |
+
selected_week = MAXIMUM_WEEK
|
144 |
+
if selected_week in week_options:
|
145 |
+
initial_week_index = week_options.index(selected_week)
|
146 |
+
|
147 |
with col_select:
|
148 |
+
position = st.selectbox(label="Position", options=POSITION_OPTIONS, index=initial_position_index)
|
149 |
with week_select:
|
150 |
+
week = st.selectbox(label="Week", options=week_options, index=initial_week_index)
|
151 |
+
url_params.update({"position": position, "week": week})
|
152 |
+
st.experimental_set_query_params(**url_params)
|
153 |
if st.experimental_get_query_params().get("refresh"):
|
154 |
st.cache_data.clear()
|
155 |
df_mrs, all_time_slots_df = load_data()
|