Skip to content
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

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

mahamakifdar19
Copy link
Contributor

@mahamakifdar19 mahamakifdar19 commented Mar 21, 2024

Description

To incorporate the "Transcript Languages" search facet into Algolia, I've added the transcript_languages_search_facet_names in the CourseRunSerializer 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

Screenshot 2024-03-21 at 4 01 20 PM

@mahamakifdar19 mahamakifdar19 changed the title feat: added transcript_languages_search_facet_names to CourseRunSerializer ENT-8400: Added transcript_languages_search_facet_names to CourseRunSerializer Mar 21, 2024
@Ali-D-Akbar Ali-D-Akbar merged commit 8949716 into openedx:master Mar 25, 2024
14 checks passed
@DawoudSheraz
Copy link
Contributor

DawoudSheraz commented Mar 25, 2024

@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()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@mahamakifdar19 mahamakifdar19 Mar 25, 2024

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.
image

Copy link
Contributor Author

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?

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.

5 participants