Skip to content

Commit

Permalink
Use DB to augment ES hits with required info
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Nov 28, 2023
1 parent 14292b1 commit b5fb362
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/api/views/media_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def related(self, request, identifier=None, *_, **__):

serializer_context = self.get_serializer_context()

serializer_class = self.get_serializer()
if serializer_class.needs_db:
results = self.get_db_results(results)

serializer = self.get_serializer(results, many=True, context=serializer_context)
return self.get_paginated_response(serializer.data)

Expand Down
4 changes: 4 additions & 0 deletions api/test/media_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ def get_terms_set(res):
or result["creator"] == item["creator"]
), f"{terms_set} {get_terms_set(result)}/{result['creator']}-{item['creator']}"

assert result["license_version"] is not None
assert result["attribution"] is not None
assert result["creator_url"] is not None


def sensitive_search_and_detail(media_type):
search_res = requests.get(
Expand Down

0 comments on commit b5fb362

Please sign in to comment.