Skip to content

support return recommendation scores by X-API-Version: 2 header#1140

Merged
zhenghaoz merged 1 commit intomasterfrom
scores
Jan 13, 2026
Merged

support return recommendation scores by X-API-Version: 2 header#1140
zhenghaoz merged 1 commit intomasterfrom
scores

Conversation

@zhenghaoz
Copy link
Collaborator

…retrieval

@zhenghaoz zhenghaoz requested a review from Copilot January 13, 2026 13:02
@zhenghaoz zhenghaoz changed the title Enhance recommendation API to support X-API-Version header for score … support return recommendation scores by X-API-Version: 2 header Jan 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the recommendation API to support the X-API-Version header for score retrieval. When clients set X-API-Version: 2, the API returns recommendation results with scores (as []cache.Score) instead of just item IDs (as []string). This maintains backward compatibility by defaulting to the original behavior when the header is not provided.

Changes:

  • Added X-API-Version header parameter to recommendation endpoint documentation and specifications
  • Implemented version checking logic in getRecommend handler to return scores when version 2 is requested
  • Added test case verifying that version 2 returns scores with proper values

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
server/rest.go Added X-API-Version header parameter to endpoint specs, updated documentation, and implemented conditional response logic to return scores for version 2
server/rest_test.go Added test case verifying X-API-Version: 2 returns scores instead of just IDs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.59%. Comparing base (93bec9c) to head (adcfeb6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1140      +/-   ##
==========================================
- Coverage   71.59%   71.59%   -0.01%     
==========================================
  Files          84       84              
  Lines       15249    15255       +6     
==========================================
+ Hits        10918    10922       +4     
- Misses       3243     3245       +2     
  Partials     1088     1088              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhenghaoz zhenghaoz merged commit eb16fc9 into master Jan 13, 2026
18 checks passed
@zhenghaoz zhenghaoz deleted the scores branch January 13, 2026 13:21
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.

2 participants