Skip to content

refactor: extract AdminDMHandler base to eliminate _verify_admin duplication#137

Merged
adrunkhuman merged 1 commit intomasterfrom
refactor/base-dm-handler
Mar 21, 2026
Merged

refactor: extract AdminDMHandler base to eliminate _verify_admin duplication#137
adrunkhuman merged 1 commit intomasterfrom
refactor/base-dm-handler

Conversation

@adrunkhuman
Copy link
Owner

Closes #117

Summary

  • Introduces AdminDMHandler[S] (handlers/base_dm_handler.py) — a generic ABC that owns the common session lifecycle interface and the duplicated _verify_admin logic
  • FixtureCreationHandler and ResultsEntryHandler now inherit from it; each implements the two abstract methods (get_session, clear_session) that bind to their respective WorkflowStateStore methods
  • has_session lives once in the base, delegating through get_session
  • DMPredictionHandler left standalone — no admin check, different session model, doesn't fit the abstraction
  • Net: -138 / +120 lines, ~80 lines of duplicated _verify_admin removed

Test plan

  • All 305 existing tests pass (uv run pytest)
  • ruff check clean on all changed files

🤖 Generated with Claude Code

…ication (#117)

`FixtureCreationHandler` and `ResultsEntryHandler` had identical ~40-line
`_verify_admin` implementations and repeated `has_session` boilerplate.

Introduces `AdminDMHandler[S]` in `handlers/base_dm_handler.py` with:
- abstract `get_session` / `clear_session` for subclasses to bind to the
  correct store methods
- concrete `has_session` delegating to `get_session`
- concrete `_verify_admin` using `self.clear_session` instead of direct
  store calls

Both admin handlers inherit from the base; `DMPredictionHandler` is left
standalone (no admin check, different session model).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@railway-app railway-app bot temporarily deployed to patient-quietude / matchday-typer-pr-137 March 21, 2026 22:59 Destroyed
@railway-app
Copy link

railway-app bot commented Mar 21, 2026

🚅 Deployed to the matchday-typer-pr-137 environment in patient-quietude

Service Status Web Updated (UTC)
matchday-typer ✅ Success (View Logs) Mar 21, 2026 at 11:01 pm

@adrunkhuman adrunkhuman merged commit b29a6a3 into master Mar 21, 2026
2 checks passed
@adrunkhuman adrunkhuman deleted the refactor/base-dm-handler branch March 21, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract base DM handler to eliminate session lifecycle duplication

1 participant