fix(display): default from-selector to last N months; keep all months selectable
All checks were successful
Deploy to K8s / deploy (push) Successful in 12s
All checks were successful
Deploy to K8s / deploy (push) Successful in 12s
Instead of hiding older months entirely, show all months in the from/to selectors but default the from-select to the last MONTHS_TO_SHOW months on page load. The "All" button resets to full history as before. Python: passes months_to_show to render_template, IIFE sets fromSelect.value. Go: adds MonthsToShow to response structs, data-months-to-show attr in templates, filters.js reads it and defaults fromSelect after hideFutureMonths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
18
app.py
18
app.py
@@ -33,12 +33,6 @@ from cache_utils import get_sheet_modified_time, read_cache, write_cache, _LAST_
|
||||
from sync_fio_to_sheets import sync_to_sheets
|
||||
from infer_payments import infer_payments
|
||||
|
||||
|
||||
def _last_n_months(months):
|
||||
"""Return the last MONTHS_TO_SHOW months; 0 means show all."""
|
||||
return months[-MONTHS_TO_SHOW:] if MONTHS_TO_SHOW > 0 else months
|
||||
|
||||
|
||||
def get_cached_data(cache_key, sheet_id, fetch_func, *args, serialize=None, deserialize=None, **kwargs):
|
||||
mod_time = get_sheet_modified_time(cache_key)
|
||||
if mod_time:
|
||||
@@ -181,7 +175,7 @@ def api_adults():
|
||||
)
|
||||
result = reconcile(members, sorted_months, transactions, exceptions)
|
||||
vm = build_adults_view_model(
|
||||
members, _last_n_months(sorted_months), result, transactions,
|
||||
members, sorted_months, result, transactions,
|
||||
datetime.now().strftime("%Y-%m"),
|
||||
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
|
||||
)
|
||||
@@ -205,7 +199,7 @@ def api_juniors():
|
||||
adapted_members = adapt_junior_members(junior_members)
|
||||
result = reconcile(adapted_members, sorted_months, transactions, exceptions)
|
||||
vm = build_juniors_view_model(
|
||||
junior_members, adapted_members, _last_n_months(sorted_months), result, transactions,
|
||||
junior_members, adapted_members, sorted_months, result, transactions,
|
||||
datetime.now().strftime("%Y-%m"),
|
||||
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
|
||||
)
|
||||
@@ -254,14 +248,14 @@ def adults_view():
|
||||
record_step("reconcile")
|
||||
|
||||
vm = build_adults_view_model(
|
||||
members, _last_n_months(sorted_months), result, transactions,
|
||||
members, sorted_months, result, transactions,
|
||||
datetime.now().strftime("%Y-%m"),
|
||||
attendance_url=attendance_url,
|
||||
payments_url=payments_url,
|
||||
bank_account=BANK_ACCOUNT,
|
||||
)
|
||||
record_step("process_data")
|
||||
return render_template("adults.html", **vm)
|
||||
return render_template("adults.html", months_to_show=MONTHS_TO_SHOW, **vm)
|
||||
|
||||
@app.route("/juniors")
|
||||
def juniors_view():
|
||||
@@ -290,14 +284,14 @@ def juniors_view():
|
||||
record_step("reconcile")
|
||||
|
||||
vm = build_juniors_view_model(
|
||||
junior_members, adapted_members, _last_n_months(sorted_months), result, transactions,
|
||||
junior_members, adapted_members, sorted_months, result, transactions,
|
||||
datetime.now().strftime("%Y-%m"),
|
||||
attendance_url=attendance_url,
|
||||
payments_url=payments_url,
|
||||
bank_account=BANK_ACCOUNT,
|
||||
)
|
||||
record_step("process_data")
|
||||
return render_template("juniors.html", **vm)
|
||||
return render_template("juniors.html", months_to_show=MONTHS_TO_SHOW, **vm)
|
||||
|
||||
@app.route("/payments")
|
||||
def payments():
|
||||
|
||||
Reference in New Issue
Block a user