Skip to content

Conversation

@shanbady
Copy link
Contributor

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/4310

Description (What does it do?)

This PR introduces a "similar resources" endpoint which is expanded onto the learning resource detail endpoint. To get similar resources for a learning resource, add '/similar' to the learning resources detail endpoint. example

http://od.odl.local:8063/api/v1/learning_resources/20/similar/

How can this be tested?

  1. Checkout this branch. have resources loaded up.
  2. pick some random resource id ( note the details of the resource like title description etc to compare to the results)
  3. visit the similar resources endpoint with this id
    http://od.odl.local:8063/api/v1/learning_resources/{resource id}/similar/
  4. By default it returns 10 resources. this can be overriden by passing in the limit as a query parameter.

@shanbady shanbady added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Oct 24, 2024
@shanbady shanbady marked this pull request as ready for review October 24, 2024 18:43
@abeglova abeglova self-assigned this Oct 25, 2024
Copy link
Contributor

@abeglova abeglova left a comment

Choose a reason for hiding this comment

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

LGTM - one minor fix required

indexes = relevant_indexes([COURSE_TYPE], [], endpoint=LEARNING_RESOURCE)
search = Search(index=",".join(indexes))
if num_resources:
search = search.extra(size=num_resources)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be num_resources+1 since the original resource is included in the results and later filtered out. Currently you get limit-1 resources in the response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! fixed

@shanbady shanbady merged commit 70eec4a into main Oct 25, 2024
12 checks passed
@shanbady shanbady deleted the shanbady/similar-resources-endpoint branch October 25, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants