feat: route imdb_search advanced title searches through Kometa IMDb Service - #3379
feat: route imdb_search advanced title searches through Kometa IMDb Service#3379chazlarson wants to merge 6 commits into
Conversation
chazlarson
left a comment
There was a problem hiding this comment.
Review
All CI checks pass and the PR is mergeable. Core change is clean. Notes below.
✅ Addressed
- Wasted
search_hashfetch (fixed in 1e5b9da): the search path previously called_graphql_json, which triggered_json_operation/search_hash— a dead GitHub-raw HTTP GET on everyimdb_search. Now split into_graphql_variables(builds constraints) and a thin_graphql_jsonwrapper; the search branch calls_graphql_variablesdirectly and no longer fetches the hash. List/watchlist paths unchanged.
🟡 Still open: no test coverage for the new search path
_service_post() and the search-via-service branch of _pagination are untested. Worth a few small tests covering:
- the
constraints/sort/limitsplit (excludinglocale/first/sortBy/sortOrder), limitomitted whendata["limit"] == 0,resultsparsing + the empty-resultsFailedpath,_service_posterror handling (≥400, invalid JSON) mirroring the existing_service_requesttests.
🟡 PR scope
Branch is stacked on imdb-service-ratings, so the diff into nightly carries all prior service work (ratings/genres/episode-ratings/parental/charts/keywords, gitpython bump, spellcheck tooling). Only ~60 lines are the actual search change. Should land after — or together with — the ratings branch.
✅ Looks good
_service_post()correctly mirrors_service_request()error handling (exception wrap, 404/not_found_ok, ≥400, JSON-parse guard).- constraints/sort/limit split matches the service contract.
- Omitting
limitwhen0correctly maps Kometa's "no limit" convention onto the service default. - List/watchlist correctly left on direct GraphQL;
item_count = 100simplification is sound. - No-fallback-for-search is reasonable (no TSV equivalent exists).
Minor nits
- Search block uses
data.get("limit", 0)while the list path usesdata["limit"]directly —validate_imdbalways setslimit, so the defensive.getis inconsistent (harmless). self._service_post(...) or {}turns aNone(404) into "No IMDb IDs Found" rather than a distinct not-found message — fine, but less precise than passingnot_found_ok=True.
chazlarson
left a comment
There was a problem hiding this comment.
Review (updated)
Both follow-up items are now resolved. CI green, mergeable.
✅ Addressed
- Wasted
search_hashfetch (1e5b9da): split_graphql_jsoninto_graphql_variables(builds constraints) and a thin_graphql_jsonwrapper. The search branch calls_graphql_variablesdirectly, so it no longer triggers_json_operation/search_hash— the dead GitHub-raw HTTP GET perimdb_searchis gone. List/watchlist paths unchanged. - Test coverage for the search path (043fdb6): added 11 tests (57 total, up from 46):
- constraints/sort/limit split (asserts
locale/first/sortBy/sortOrderexcluded from constraints;sortsplit correctly), limitomitted whendata['limit'] == 0,- results parsing, empty-results and
None-responseFailedpaths, - service-failure propagation (no fallback dataset for search),
_service_postsuccess / 404not_found_ok/ ≥400 / invalid JSON / connection-error handling, mirroring the_service_requesttests.- Autouse fixture patches the module logger to a no-op (it's
Nonein tests) so the search path'slogger.ghost/exorcisecalls don't crash.tests/is excluded from pyright, so the MagicMock-assignment warnings there are non-issues.
- constraints/sort/limit split (asserts
🟡 Scope note (unchanged)
Branch is stacked on imdb-service-ratings, so the diff into nightly carries all prior service work (ratings/genres/episode-ratings/parental/charts/keywords, gitpython bump, spellcheck tooling). Only the search change + its tests are new here. Should land after — or together with — the ratings branch.
✅ Looks good
_service_post()mirrors_service_request()error handling and is now test-covered.- constraints/sort/limit split matches the service contract.
- Omitting
limitwhen0correctly maps Kometa's "no limit" convention onto the service default. - List/watchlist correctly left on direct GraphQL.
- No-fallback-for-search is reasonable (no TSV equivalent exists) and is now asserted by a test.
Minor nits (non-blocking)
- Search block uses
data.get("limit", 0)while the list path usesdata["limit"]directly — harmless inconsistency sincevalidate_imdbalways setslimit. self._service_post(...) or {}turns aNone(404) into "No IMDb IDs Found" rather than a distinct not-found message — fine, but less precise than passingnot_found_ok=True.
badja-dev
left a comment
There was a problem hiding this comment.
the new search branch in _pagination calls logger.ghost(...) / logger.exorcise() unguarded, while every other new method in this PR (_service_request, _service_post, get_rating, etc.) wraps logger calls in if logger:
Once rebased onto nightly and the above is fix, looks good to me
22abc30 to
5d61ead
Compare
|
@badja-dev can you approve if happy? |
…ervice Adds _service_post() helper for POST-based service calls and rewrites the search branch of _pagination() to POST constraints/sort/limit to /search/advanced instead of hitting IMDb GraphQL directly. The service handles pagination and caching server-side; Kometa receives the full ordered result list in one response. List and watchlist paths remain unchanged on direct GraphQL.
Split _graphql_json into _graphql_variables (builds the constraint dict) and a thin _graphql_json wrapper that adds the persisted-query envelope. The search branch of _pagination now calls _graphql_variables directly, so it no longer triggers _json_operation/search_hash — eliminating a dead GitHub raw HTTP fetch on every imdb_search. List/watchlist paths are unchanged.
Adds 11 tests for the new advanced-search-via-service path: - constraints/sort/limit split (excludes locale/first/sortBy/sortOrder) - limit omitted when data['limit'] == 0 - results parsing, empty-results and None-response Failed paths - service failure propagation (no fallback dataset for search) - _service_post success, 404 not_found_ok, >=400, invalid JSON, and connection-error handling (mirrors _service_request tests) Adds an autouse fixture patching the module logger to a no-op so the search path's logger.ghost/exorcise calls don't crash.
5d61ead to
c83caf7
Compare
What type of PR is this?
Description
Routes
imdb_searchbuilder advanced title searches through the Kometa IMDb Service (POST /search/advanced) instead of hitting IMDb GraphQL directly.What changed:
_service_post()- POST counterpart to_service_request, with the same error handling (exception wrapping, 404/400+ checks, JSON parse guard)_pagination(): calls_graphql_jsonto build constraint variables (preserving all existing translation tables and constraint logic), splits intoconstraints/sort/limit, and sends a single POST to/search/advancedTested: 46 existing IMDb tests pass. The change is purely a routing swap - all constraint-building logic and translation tables are preserved as-is.
Have you updated the CHANGELOG.md?