Skip to content

refactor: replace dashboard if/elif routing with declarative tables#44

Merged
pratyush618 merged 1 commit intomasterfrom
refactor/dashboard-routing
Mar 22, 2026
Merged

refactor: replace dashboard if/elif routing with declarative tables#44
pratyush618 merged 1 commit intomasterfrom
refactor/dashboard-routing

Conversation

@pratyush618
Copy link
Copy Markdown
Collaborator

Summary

  • Replace 95-line _handle_get() and 29-line _handle_post() if/elif chains with four declarative routing tables
  • Extract handler functions for endpoints with validation logic
  • Adding a new endpoint is now a one-liner in the route table instead of another elif branch

Changes

  • Exact-match routes use dict lookup (O(1)) for 14 GET and 1 POST endpoint
  • Parameterized routes use regex lists for 5 GET and 5 POST endpoints with path params
  • _BadRequest and _NotFound exceptions replace scattered self._json_response({"error": ...}, status=N); return patterns
  • _extract_path_segment() removed — replaced by regex group capture
  • _parse_int_qs() now raises _BadRequest instead of returning None

Test plan

  • uv run python -m pytest tests/python/test_dashboard.py -q — all 18 tests pass
  • uv run ruff check py_src/taskito/dashboard.py — clean
  • uv run ruff format --check py_src/taskito/dashboard.py — clean
  • All 30+ API endpoints return identical responses to before

Replace 95-line _handle_get() and 29-line _handle_post() if/elif
chains with four declarative routing tables: exact-match dicts for
O(1) lookup and regex lists for parameterized paths. Extract handler
functions for endpoints with validation logic. Add _BadRequest and
_NotFound exceptions for clean error responses from handlers.

Adding a new endpoint is now a one-liner in the route table instead
of another elif branch with manual path parsing.
@pratyush618 pratyush618 merged commit 9f862e7 into master Mar 22, 2026
11 checks passed
@pratyush618 pratyush618 deleted the refactor/dashboard-routing branch March 31, 2026 17:21
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.

1 participant