Split views_api into a domain package; unshadow /accounts/hierarchy #61
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/views-api-package"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Seventh and final PR of the refactor series (stacked on #60 → #59 → #58 → #57 → #56 → #55; merge in order).
Three commits, review each separately:
(methods, path, endpoint)table oflibra_api_router— 73 routes — including the wart it must not silently change.git diff --color-moved): the 4,100-lineviews_api.pybecomes aviews_api/package with one module per domain —accounts,entries,payments(balances + invoices + settlements + manual payment requests),settings_reports,reconciliation,permissions(+equity),admin(chart accounts, sync, roles). Shared imports/helpers live in_shared.py;_extract_entry_id/_SYSTEM_LINK_PREFIXESmove tobeancount_format.py(pure entry-dict parsing).libra/__init__.pyis untouched — the package__init__builds the samelibra_api_router. The snapshot confirms the 73-route set is identical and both order-sensitive overlap families keep their relative order (each lives inside a single module)./api/v1/accounts/hierarchywas registered ~3,300 lines after/accounts/{account_id}and therefore shadowed — the endpoint has been unreachable (404 viaaccount_id="hierarchy") since it was added. Now registered before the param routes, with a functional reachability test.Largest module is now
entries.pyat 1,205 lines (from 4,121); everything else is 170–980.Tests: 180 passed, 3 skipped (route snapshot + overlap-order + hierarchy reachability added).
This completes the refactor series from
docs/CODE-REVIEW-2026-06.md. After the full stack merges, these issues are fixed and can be closed manually once deployed: libra-#22 (was already fixed, noted in #56), #23, #35, #36, #38, #39, #51, #52, #53, #54.🤖 Generated with Claude Code
FastAPI matches in registration order; the views_api split must keep the (methods, path, endpoint) table byte-identical. The snapshot also records the known wart it must NOT silently change: /accounts/hierarchy is registered after /accounts/{account_id} and therefore shadowed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>FastAPI matches in registration order, and hierarchy was registered ~3,300 lines after the {account_id} route — every request resolved as account_id="hierarchy" and 404'd, so the endpoint has been unreachable since it was added. Moved above the param routes in the accounts module, with a functional reachability test and an updated route snapshot (literal-before-param is now asserted for both overlap families). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.