-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENT-8400: Added transcript_languages_search_facet_names to CourseRunSerializer #4296
Conversation
82e4638
to
8d8b157
Compare
8d8b157
to
dac2239
Compare
dac2239
to
b840fa0
Compare
b840fa0
to
b9fae06
Compare
@Ali-D-Akbar I hope you checked that this does not cause N+1 issues. |
@@ -1018,6 +1018,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer): | |||
required=False, many=True, slug_field='code', | |||
queryset=LanguageTag.objects.prefetch_related('translations').order_by('name') | |||
) | |||
transcript_languages_search_facet_names = serializers.SerializerMethodField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the field name is not good/descriptive -- if you want language names only, it should be transcript_language_names. Though I don't know why we need a new field for this -- when we have language info already available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DawoudSheraz The field name transcript_languages_search_facet_names
suggests that it's specifically for Algolia search facets. We already have language information (stored in the transcript_languages attribute) in the form of language codes. Now, we need to extract language names from these codes to store in Algolia.
That's why we introduced this new variable, which indicates that it contains language names mapped to each language code, specifically for use in Algolia search facets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is only needed for Algolia(and for enterprise usage), the API is not the right place to add this information. It should be done on Enterprise algolia code level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DawoudSheraz In past, this approach has been explored here where the catalog can use the langcodes method to convert language codes into human-readable names. However, this method didn't align perfectly with the LanguageTag
model data stored in the course-discovery
database and in order to sync it, we would need to replicate the LanguageTag model in the catalog.
A similar strategy has been used previously for similar tasks (here). Language names were included in the CourseRunSerializer within course-discovery. This setup allows the enterprise-catalog to retrieve language names seamlessly through the API endpoint, eliminating the need to parse language codes or replicate the LanguageTag model from course-discovery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In past, this approach has been explored #2990
And
A similar strategy has been used previously for similar tasks #2990
both seem to be referring to same PR? Anyways, while I get the context, I would suggest finding a better way for doing this. I personally do not agree with how it has been done in the past 🙂 . Discovery APIs already carry too much information and adding an new field for a very specific consumer is not worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DawoudSheraz Alternative approaches that have been considered in the past are listed in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DawoudSheraz I will discuss with team markhors, and going forward, we will explore more effective methods of obtaining this information. Currently, replicating such information in the catalog seems like a substantial effort. Could you please confirm if these changes are ready for deployment at this time, and we can work on refining the approach in the future?
Description
To incorporate the "Transcript Languages" search facet into Algolia, I've added the
transcript_languages_search_facet_names
in theCourseRunSerializer
to ensure it is included in the API response.It contains a list of available human-readable video transcript language names parsed from a language code.
Jira Ticket
ENT-8400