This PR fixes a bug with the similar resources endpoint that happens when a opensearch result is missing the published attribute (happens on unpublished contentfiles).
How can this be tested?
I have included a test that will fail on main and pass on this branch.
You can also visit the similar resources endpoint http://open.odl.local:8063/api/v1/learning_resources/181/similar/ and validate that only learning resources are returned.
Additional Context
Restricting this to just learning resources should fix the issue but I have also moved the check for "published" to the django filter instead of the opensearch response for added measure since we cant rely on that attribute in the index.
What are the relevant tickets?
Fixes https://github.com/mitodl/mit-learn/issues/1862
Description (What does it do?)
This PR fixes a bug with the similar resources endpoint that happens when a opensearch result is missing the published attribute (happens on unpublished contentfiles).
How can this be tested?
I have included a test that will fail on main and pass on this branch. You can also visit the similar resources endpoint
http://open.odl.local:8063/api/v1/learning_resources/181/similar/
and validate that only learning resources are returned.Additional Context
Restricting this to just learning resources should fix the issue but I have also moved the check for "published" to the django filter instead of the opensearch response for added measure since we cant rely on that attribute in the index.