You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the recent update to source course metadata from language-specific metadata fields, there are multiple instances in our codebase where this retrieval logic is repeated. This redundancy can lead to maintenance challenges and potential bugs. We need to refactor the code to use a dynamic utility function that centralizes this logic and retrieves all available fields.
Tasks:
Create a Dynamic Utility Function:
Develop a utility function that dynamically retrieves all metadata fields from course.metadata based on the specified language.
The function should fall back to the root object fields if the metadata fields are not available.
constgetCourseMetadata=(course,language)=>{constmetadata=course?.metadata?.[language]||{};constrootFields=course||{};// Combine metadata and root fields, giving priority to metadatareturnObject.keys(rootFields).reduce((fields,key)=>{fields[key]=metadata[key]||rootFields[key];returnfields;},{});};
Refactor Existing Code:
Identify all instances in the codebase where metadata fields are being fetched from course.metadata.
Replace these instances with calls to the new utility function.
Description:
With the recent update to source course metadata from language-specific metadata fields, there are multiple instances in our codebase where this retrieval logic is repeated. This redundancy can lead to maintenance challenges and potential bugs. We need to refactor the code to use a dynamic utility function that centralizes this logic and retrieves all available fields.
Tasks:
Create a Dynamic Utility Function:
course.metadata
based on the specified language.Refactor Existing Code:
course.metadata
.Example refactor:
Update Components and Functions:
Test the Refactor:
The text was updated successfully, but these errors were encountered: