Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -166,6 +166,7 @@ def quote_year_choices():
|
|
166 |
def quote_month_choices(year=None):
|
167 |
"""
|
168 |
Returns a sorted list of valid month strings for a given year, always at least [''].
|
|
|
169 |
"""
|
170 |
df = get_quotes_df()
|
171 |
if (
|
@@ -175,13 +176,20 @@ def quote_month_choices(year=None):
|
|
175 |
and not df.empty
|
176 |
):
|
177 |
subset = df[df["Year"].astype(str) == str(year)]
|
|
|
|
|
|
|
178 |
try:
|
179 |
months = pd.to_numeric(subset["Month"], errors="coerce").dropna().astype(int)
|
180 |
months = [str(m) for m in months if 1 <= m <= 12]
|
181 |
months = sorted(set(months))
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
184 |
return [""]
|
|
|
185 |
return [""]
|
186 |
|
187 |
def quotes_summary(year=None, month=None):
|
@@ -215,10 +223,12 @@ def get_rep_quotes_filtered(rep, year=None, month=None):
|
|
215 |
|
216 |
def update_month_choices_summary(year):
|
217 |
months = quote_month_choices(year)
|
|
|
218 |
return gr.Dropdown.update(choices=months, value="")
|
219 |
|
220 |
def update_month_choices(year):
|
221 |
months = quote_month_choices(year)
|
|
|
222 |
return gr.Dropdown.update(choices=months, value="")
|
223 |
|
224 |
# -------------------- UI LAYOUT --------------------
|
|
|
166 |
def quote_month_choices(year=None):
|
167 |
"""
|
168 |
Returns a sorted list of valid month strings for a given year, always at least [''].
|
169 |
+
Also prints debug output to help troubleshoot.
|
170 |
"""
|
171 |
df = get_quotes_df()
|
172 |
if (
|
|
|
176 |
and not df.empty
|
177 |
):
|
178 |
subset = df[df["Year"].astype(str) == str(year)]
|
179 |
+
if subset.empty:
|
180 |
+
print(f"[DEBUG] No quotes found for year {year}. Returning [''].")
|
181 |
+
return [""]
|
182 |
try:
|
183 |
months = pd.to_numeric(subset["Month"], errors="coerce").dropna().astype(int)
|
184 |
months = [str(m) for m in months if 1 <= m <= 12]
|
185 |
months = sorted(set(months))
|
186 |
+
result = [""] + months if months else [""]
|
187 |
+
print(f"[DEBUG] Year {year}: Months dropdown = {result}")
|
188 |
+
return result
|
189 |
+
except Exception as e:
|
190 |
+
print(f"[DEBUG] Exception in quote_month_choices for year {year}: {e}")
|
191 |
return [""]
|
192 |
+
print(f"[DEBUG] No valid year or columns missing. Returning [''].")
|
193 |
return [""]
|
194 |
|
195 |
def quotes_summary(year=None, month=None):
|
|
|
223 |
|
224 |
def update_month_choices_summary(year):
|
225 |
months = quote_month_choices(year)
|
226 |
+
print(f"[DEBUG] update_month_choices_summary({year}) -> {months}")
|
227 |
return gr.Dropdown.update(choices=months, value="")
|
228 |
|
229 |
def update_month_choices(year):
|
230 |
months = quote_month_choices(year)
|
231 |
+
print(f"[DEBUG] update_month_choices({year}) -> {months}")
|
232 |
return gr.Dropdown.update(choices=months, value="")
|
233 |
|
234 |
# -------------------- UI LAYOUT --------------------
|