refactor: replace dashboard if/elif routing with declarative tables#44
Merged
pratyush618 merged 1 commit intomasterfrom Mar 22, 2026
Merged
refactor: replace dashboard if/elif routing with declarative tables#44pratyush618 merged 1 commit intomasterfrom
pratyush618 merged 1 commit intomasterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_handle_get()and 29-line_handle_post()if/elif chains with four declarative routing tablesChanges
_BadRequestand_NotFoundexceptions replace scatteredself._json_response({"error": ...}, status=N); returnpatterns_extract_path_segment()removed — replaced by regex group capture_parse_int_qs()now raises_BadRequestinstead of returning NoneTest plan
uv run python -m pytest tests/python/test_dashboard.py -q— all 18 tests passuv run ruff check py_src/taskito/dashboard.py— cleanuv run ruff format --check py_src/taskito/dashboard.py— clean