refactor(app): extract view-model builders into scripts/views.py #15

Merged
kacerr merged 2 commits from feat/m5-python-views-extraction into main 2026-05-07 15:26:42 +02:00
Owner

Summary

  • Extracts ~350 lines of inline per-row computation from adults_view, juniors_view, and payments into three pure builder functions in scripts/views.py: build_adults_view_model, build_juniors_view_model, build_payments_view_model
  • Moves get_month_labels, group_payments_by_person, and adapt_junior_members out of app.py into views.py (view-model concerns, not Flask concerns)
  • Route handlers now contain only cache/IO calls + record_step timing + a single render_template call (~25 lines each vs 167/205/35 before)
  • No behaviour change — all 27 tests pass

Why

Prep for M5 of the Go rewrite: the /api/* shadow endpoints will be one-liners calling the same builders + jsonify(vm), with no logic duplication.

Test plan

  • make test — 27/27 green
  • Manual smoke: /adults, /juniors, /payments render identically to before

🤖 Generated with Claude Code

## Summary - Extracts ~350 lines of inline per-row computation from `adults_view`, `juniors_view`, and `payments` into three pure builder functions in `scripts/views.py`: `build_adults_view_model`, `build_juniors_view_model`, `build_payments_view_model` - Moves `get_month_labels`, `group_payments_by_person`, and `adapt_junior_members` out of `app.py` into `views.py` (view-model concerns, not Flask concerns) - Route handlers now contain only cache/IO calls + `record_step` timing + a single `render_template` call (~25 lines each vs 167/205/35 before) - No behaviour change — all 27 tests pass ## Why Prep for M5 of the Go rewrite: the `/api/*` shadow endpoints will be one-liners calling the same builders + `jsonify(vm)`, with no logic duplication. ## Test plan - [x] `make test` — 27/27 green - [ ] Manual smoke: `/adults`, `/juniors`, `/payments` render identically to before 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kacerr added 1 commit 2026-05-07 15:22:24 +02:00
refactor(app): extract view-model builders into scripts/views.py
All checks were successful
Deploy to K8s / deploy (push) Successful in 8s
b562ce3201
Pull 350+ lines of inline per-row computation out of adults_view,
juniors_view, and payments into three pure builder functions with no
Flask globals or IO dependencies. Route handlers now contain only
cache/IO calls and a single render_template. No behaviour change —
all 27 tests pass.

Also moves get_month_labels, group_payments_by_person, and
adapt_junior_members out of app.py. Prep for /api/* shadow endpoints
(M5 Go parity).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kacerr added 1 commit 2026-05-07 15:24:41 +02:00
fix(app): restore missing import re needed by qr_code route
All checks were successful
Deploy to K8s / deploy (push) Successful in 6s
2eec51bb34
Accidentally removed when moving group_payments_by_person to views.py;
re.match in qr_code caused a 500 on every QR request.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kacerr merged commit 32a16ff50d into main 2026-05-07 15:26:42 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kacerr/fuj-management#15