Skip to content

Cap score set search and remove its per-result queries #885

Description

@bencap

Problem

Score set search does unbounded work per request.

  • search_score_sets (routers/score_sets.py:699) caps results at SCORE_SET_SEARCH_MAX_LIMIT only when publication_identifiers is absent. A search with publication identifiers has no cap, and search_my_score_sets (:812) has none either.
  • The search routes build the full score set view model for each result and then trim it to the short one, which triggers about 15 lazy-load queries per result.
  • get_filter_options_for_search (:753, through fetch_score_set_search_filter_options in lib/score_sets.py) loads every matching score set plus 8–15 queries each. The ui calls it after every pause in typing, and the handler keeps running after the ui cancels.

Scope

  • Apply the cap to every search, including publication-identifier searches and /me/score-sets/search.
  • Build the short view model directly, with loader options for the fields it serializes.
  • Compute filter options with aggregate queries over the matching set, not by loading score sets.

Acceptance criteria

  • No search route returns more than SCORE_SET_SEARCH_MAX_LIMIT results.
  • Query-count tests assert a constant number of queries for search and for filter options as the number of matches grows.
  • Search and filter-option responses are unchanged for the existing tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app: backendTask implementation touches the backendapp: databaseTask implementation requires database changes

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions