Skip to content

feat(api)!: remove DictQuery / SentenceQuery / UsageQuery - #70

Merged
torridfish merged 1 commit into
mainfrom
chore/remove-unused-query-endpoints
Sep 15, 2026
Merged

torridfish merged 1 commit into
mainfrom
chore/remove-unused-query-endpoints

Conversation

@torridfish

@torridfish torridfish commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

目的

Keep only MarkAccent, which is the service's sole purpose, and remove the DictQuery / SentenceQuery / UsageQuery endpoints. All three were HTML scrapes of external sites and saw little use (as recorded in #62), and one of them was broken outright: DictQuery had been returning 404 for every input since EDRDG moved JMdictDB behind a monthly-rotating password gate — the gate answers 200, 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_client had no other consumer.
    • main.py: drop the three include_router calls and the app.state.http_client setup/teardown; the lifespan now only warms the accent engines, and the module docstring lists just the two MarkAccent routes.
    • pyproject.toml / uv.lock: drop beautifulsoup4 from runtime dependencies and move httpx to the dev group.
    • README.md: trim the endpoint table to the two MarkAccent routes, record why the three were removed, and delete the "How to use a shared httpx.AsyncClient" guide that documented the now-deleted api.dependencies.
  • 關鍵實作:
    • bs4 was reachable only from the two EDRDG scrapes, so it leaves the runtime closure entirely — uv lock drops both beautifulsoup4 and soupsieve.
    • httpx survives only as a test dependency (tests/test_request_limits.py uses ASGITransport), so it moves to dev rather than being removed, and the running service no longer holds a shared connection pool at all.
    • No accent-pipeline code is touched; the removal is confined to the routers, the deleted dependency module, and the app wiring.

關聯 Issue

Closes #54.
Refs #62.

附註

  • Breaking change. 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.
  • Consumer audit: no live consumer remains. Checked every repo in the org (code search plus local clones) for the removed paths:
    • jpcorrect-backend reverse-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 frontend akuma only has src/components/AccentEditor/core/api/markAccentClient.ts and references mark-accent alone. Its own tests are unaffected — api_tools_test.go uses /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-bot was the only direct consumer, calling API_URL itself rather than going through jpcorrect-backend: cogs/dict_query.py → /api/DictQuery/ (already dead behind the JMdictDB gate) and cogs/usage_query.py → /api/UsageQuery/URL/. That repo is no longer used and has now been archived, so neither call has a live caller.
    • No other repo references the removed paths; the remaining hits are jpcorrect-backend's generated swagger and two old meeting-minutes files in talkuma-docs.
  • Local verification: Ruff clean, ruff format --check clean, strict mypy clean (28 source files), 127 pytest cases passed. The app was also booted through its real lifespan: openapi.json lists exactly /api/MarkAccent/ and /api/MarkAccent/stream/, MarkAccent on 東京 returns 200 with とうきょう and its per-mora accent, the five removed paths return 404, and app.state no longer carries an http_client.
  • CI is unaffected by the removal: the CD and Docker-build smoke tests only exercise /openapi.json and /api/MarkAccent/.
  • This settles the "Out of scope (parked)" section of [Epic] Make MarkAccent a standalone pitch-accent service (drop OJAD dependency) #62 — those endpoints and their known bugs are no longer this repo's problem, so the remaining repo-split question there is now narrower.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

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>
@torridfish
torridfish force-pushed the chore/remove-unused-query-endpoints branch from acb9d83 to 161627d Compare September 14, 2026 15:17
@torridfish torridfish changed the title chore!: remove DictQuery / SentenceQuery / UsageQuery feat(api)!: remove DictQuery / SentenceQuery / UsageQuery Sep 14, 2026
@github-actions

Copy link
Copy Markdown

🛡️ PR Quality Check Summary

✅ PR Title: Passed (Length: 57/75, Format: OK). feat(api)!: remove DictQuery / SentenceQuery / UsageQuery
✅ Branch Name: Follows naming convention (chore/remove-unused-query-endpoints)
✅ Commit Messages: All 1 commit(s) passed (Length, Format, Case)
✅ Conflicts: No merge conflict markers found
✅ Python Quality: All checks passed.


🎉 All checks passed!

@wade00754 wade00754 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

審查結論: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 結果,未另於本機重跑完整測試。

@torridfish
torridfish added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit 7857f44 Sep 15, 2026
26 of 27 checks passed
@torridfish
torridfish deleted the chore/remove-unused-query-endpoints branch September 15, 2026 14:14
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.

DictQuery returns 404 for every word: EDRDG JMdictDB is now behind a site-wide password gate

2 participants