Skip to content

fix: honor MAX_RESULTS default cap in recommendations (issue #1881) - #1915

Open
ionfwsrijan wants to merge 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1881-recommender-max-results
Open

fix: honor MAX_RESULTS default cap in recommendations (issue #1881)#1915
ionfwsrijan wants to merge 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1881-recommender-max-results

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

MAX_RESULTS = 3 in recommender.py was dead code. get_recommendations only capped results when max_results was non-None, and the route always passed max_results=None, so the recommendation API returned every relevant project (28–30 on a broad "python" query) — an unbounded payload far beyond what the UI uses.

Fix

  • src/utils/recommender.py: get_recommendations now honors MAX_RESULTS as the default cap — scored_projects[:MAX_RESULTS] when max_results is None, with explicit max_results still able to override.
  • tests/test_basic.py: added test_get_recommendations_default_cap_applies, asserting a broad query returns ≤ 3 by default while an explicit max_results=100 returns more.

Files changed

  • src/utils/recommender.py — the default result cap now takes effect.
  • tests/test_basic.py — new regression test for the default cap.

Testing

  • Measured against the real engine with a seeded DB: broad "python" queries return 28–30 uncapped and exactly 3 with the default; the existing test_get_recommendations_max_three and all other recommender tests (test_tiebreaker, test_case_sensitivity, determinism/format checks) remain satisfied. Full suite runs in CI (local app boot is blocked by the pre-existing App fails to boot: NameError: name 're' is not defined in portfolio_analyzer.py #1810).

Closes #1881

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MAX_RESULTS=3 is dead code - recommendation API returns unbounded results

1 participant