feat(api)!: remove DictQuery / SentenceQuery / UsageQuery - #70
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
MarkAccent is the service's only purpose. The other three endpoints were HTML scrapes of external sites, all saw little use, and DictQuery had been returning 404 for every input since EDRDG moved JMdictDB behind a monthly-rotating password gate. Removing them makes the whole service request-time offline, matching what the README already claimed for the accent pipeline: - delete api/dict_query.py, api/sentence_query.py, api/usage_query.py - delete api/dependencies.py (get_http_client had no other consumer) and the app.state.http_client lifespan setup/teardown in main.py - drop beautifulsoup4 from runtime deps; move httpx to the dev group (only tests/test_request_limits.py still needs it) - README: trim the endpoint table, record why the three went, and drop the shared-httpx.AsyncClient guide that documented api.dependencies BREAKING CHANGE: remove `POST /api/DictQuery/`, `/api/SentenceQuery/`, `/api/UsageQuery/HeadWords/`, `/api/UsageQuery/URL/` and `/api/UsageQuery/IdDetails/`; they now return 404. Only `/api/MarkAccent/` and `/api/MarkAccent/stream/` remain. Refs #54. Refs #62. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
acb9d83 to
161627d
Compare
🛡️ PR Quality Check Summary✅ PR Title: Passed (Length: 57/75, Format: OK). 🎉 All checks passed! |
wade00754
left a comment
There was a problem hiding this comment.
審查結論:Approve,未發現需要阻擋合併的問題。
已檢視 161627d 的變更及剩餘程式引用。三組查詢 router 與共用 HTTP client 的移除完整;執行期沒有殘留對被刪模組、httpx 或 bs4 的引用,httpx 保留在 dev 依賴供 ASGI 測試使用,pyproject.toml 與 uv.lock 也同步調整。MarkAccent 的啟動暖機、路由及核心流程未被更動。
端點回傳 404 是本次明確宣告的功能移除,PR 也已記錄消費端盤點,因此不把既定 breaking change 另列為缺陷。GitHub 上的 Lint/type-check/pytest 與 Docker 離線 smoke test 均通過;本次採靜態審查及既有 CI 結果,未另於本機重跑完整測試。
目的
Keep only
MarkAccent, which is the service's sole purpose, and remove theDictQuery/SentenceQuery/UsageQueryendpoints. All three were HTML scrapes of external sites and saw little use (as recorded in #62), and one of them was broken outright:DictQueryhad been returning404for every input since EDRDG moved JMdictDB behind a monthly-rotating password gate — the gate answers200, so the scraper parsed 0 rows and emitted its own 404, and no selector fix could reach past it (re-diagnosis in #54).Removing them makes the whole service request-time offline, which is what the README already claimed for the accent pipeline ("fully local and offline… no network calls"). These three endpoints were the last thing contradicting it.
方法/實作說明
Delete the three routers plus the HTTP-client infrastructure that existed only to serve them, then prune the dependencies and docs that became dead as a result.
api/dict_query.py,api/sentence_query.py,api/usage_query.py: deleted (EDRDG JMdictDB, EDRDG WWWJDIC and Yahoo scrapes respectively).api/dependencies.py: deleted —get_http_clienthad no other consumer.main.py: drop the threeinclude_routercalls and theapp.state.http_clientsetup/teardown; the lifespan now only warms the accent engines, and the module docstring lists just the twoMarkAccentroutes.pyproject.toml/uv.lock: dropbeautifulsoup4from runtime dependencies and movehttpxto thedevgroup.README.md: trim the endpoint table to the twoMarkAccentroutes, record why the three were removed, and delete the "How to use a sharedhttpx.AsyncClient" guide that documented the now-deletedapi.dependencies.bs4was reachable only from the two EDRDG scrapes, so it leaves the runtime closure entirely —uv lockdrops bothbeautifulsoup4andsoupsieve.httpxsurvives only as a test dependency (tests/test_request_limits.pyusesASGITransport), so it moves todevrather than being removed, and the running service no longer holds a shared connection pool at all.關聯 Issue
Closes #54.
Refs #62.
附註
POST /api/DictQuery/,/api/SentenceQuery/,/api/UsageQuery/HeadWords/,/api/UsageQuery/URL/and/api/UsageQuery/IdDetails/now return 404. Only/api/MarkAccent/and/api/MarkAccent/stream/remain.jpcorrect-backendreverse-proxies all five as live routes (internal/api/api.go:133-137→/v1/dict-query,/v1/sentence-query,/v1/usage-query/*), so those proxy routes will start returning 404. Nothing consumes them, though: the frontendakumaonly hassrc/components/AccentEditor/core/api/markAccentClient.tsand referencesmark-accentalone. Its own tests are unaffected —api_tools_test.gouses/api/DictQuery/only as an arbitrary target against a stub server. Removing that proxy layer (handlers, models, routes, regenerated swagger) is follow-up cleanup on that repo, not a functional break.discord-botwas the only direct consumer, callingAPI_URLitself rather than going throughjpcorrect-backend:cogs/dict_query.py→/api/DictQuery/(already dead behind the JMdictDB gate) andcogs/usage_query.py→/api/UsageQuery/URL/. That repo is no longer used and has now been archived, so neither call has a live caller.jpcorrect-backend's generated swagger and two old meeting-minutes files intalkuma-docs.ruff format --checkclean, strict mypy clean (28 source files), 127 pytest cases passed. The app was also booted through its real lifespan:openapi.jsonlists exactly/api/MarkAccent/and/api/MarkAccent/stream/,MarkAccenton東京returns 200 withとうきょうand its per-mora accent, the five removed paths return 404, andapp.stateno longer carries anhttp_client./openapi.jsonand/api/MarkAccent/.🤖 Generated with Claude Code