feat(display): limit /adults and /juniors to last N months by default
All checks were successful
Deploy to K8s / deploy (push) Successful in 17s

Show only the last MONTHS_TO_SHOW months (default 5) in the fee table columns
so the page fits on screen without horizontal scrolling. Reconciliation still
runs over the full month history so balances, credits, and debts are unaffected.
Set MONTHS_TO_SHOW=0 to show all months. Implemented in both Python and Go.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 11:18:55 +02:00
parent 37fc17cf9c
commit c0487e3af0
5 changed files with 182 additions and 7 deletions

16
app.py
View File

@@ -19,7 +19,7 @@ sys.path.append(str(scripts_dir))
from config import (
ATTENDANCE_SHEET_ID, PAYMENTS_SHEET_ID, JUNIOR_SHEET_GID,
BANK_ACCOUNT, CREDENTIALS_PATH,
BANK_ACCOUNT, CREDENTIALS_PATH, MONTHS_TO_SHOW,
)
from attendance import get_members_with_fees, get_junior_members_with_fees
from match_payments import reconcile, fetch_sheet_data, fetch_exceptions
@@ -33,6 +33,12 @@ 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:
@@ -175,7 +181,7 @@ def api_adults():
)
result = reconcile(members, sorted_months, transactions, exceptions)
vm = build_adults_view_model(
members, sorted_months, result, transactions,
members, _last_n_months(sorted_months), result, transactions,
datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
)
@@ -199,7 +205,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, sorted_months, result, transactions,
junior_members, adapted_members, _last_n_months(sorted_months), result, transactions,
datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url, payments_url=payments_url, bank_account=BANK_ACCOUNT,
)
@@ -248,7 +254,7 @@ def adults_view():
record_step("reconcile")
vm = build_adults_view_model(
members, sorted_months, result, transactions,
members, _last_n_months(sorted_months), result, transactions,
datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url,
payments_url=payments_url,
@@ -284,7 +290,7 @@ def juniors_view():
record_step("reconcile")
vm = build_juniors_view_model(
junior_members, adapted_members, sorted_months, result, transactions,
junior_members, adapted_members, _last_n_months(sorted_months), result, transactions,
datetime.now().strftime("%Y-%m"),
attendance_url=attendance_url,
payments_url=payments_url,