fix: update response (#30712)
- add course_run_key in API response - remove course_key from API response VAN-986
This commit is contained in:
@@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_personalized_course_recommendations(user_id):
|
||||
""" get personalize recommendations from Amplitude. """
|
||||
""" Get personalize recommendations from Amplitude. """
|
||||
headers = {
|
||||
'Authorization': f'Api-Key {settings.AMPLITUDE_API_KEY}',
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -373,7 +373,8 @@ class CourseRecommendationApiView(APIView):
|
||||
course_data = get_course_data(course_id)
|
||||
if course_data:
|
||||
recommended_courses.append({
|
||||
'course_key': course_data['key'],
|
||||
'course_run_key': [run['key'] for run in course_data['course_runs']
|
||||
if run['availability'] == 'Current'][-1],
|
||||
'title': str(course_data['title']),
|
||||
'logo_image_url': course_data['owners'][0]['logo_image_url'],
|
||||
'marketing_url': course_data.get('marketing_url')
|
||||
|
||||
@@ -15,19 +15,19 @@ class RecommendationsPanel extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
onCourseSelect(courseKey) {
|
||||
onCourseSelect(courseRunKey) {
|
||||
window.analytics.track('edx.bi.user.recommended.course.click', {
|
||||
course_key: courseKey,
|
||||
course_key: courseRunKey,
|
||||
is_personalized_recommendation: this.state.isPersonalizedRecommendation,
|
||||
});
|
||||
|
||||
let recommendedCourses = Cookies.get(this.cookieName);
|
||||
if (typeof recommendedCourses === 'undefined') {
|
||||
recommendedCourses = { course_keys: [courseKey] };
|
||||
recommendedCourses = { course_keys: [courseRunKey] };
|
||||
} else {
|
||||
recommendedCourses = JSON.parse(recommendedCourses);
|
||||
if (!recommendedCourses.course_keys.includes(courseKey)) {
|
||||
recommendedCourses.course_keys.push(courseKey);
|
||||
if (!recommendedCourses.course_keys.includes(courseRunKey)) {
|
||||
recommendedCourses.course_keys.push(courseRunKey);
|
||||
}
|
||||
}
|
||||
recommendedCourses['is_personalized_recommendation'] = this.state.isPersonalizedRecommendation;
|
||||
@@ -64,7 +64,7 @@ class RecommendationsPanel extends React.Component {
|
||||
<div className={this.state.coursesList.length ? '' : 'spinner-container'}>
|
||||
{this.state.coursesList.length ? this.state.coursesList.map(course => (
|
||||
<a href={course.marketing_url} className="course-link"
|
||||
onClick={() => this.onCourseSelect(course.course_key)}>
|
||||
onClick={() => this.onCourseSelect(course.course_run_key)}>
|
||||
<div className="course-card box-shadow-down-1 bg-white mb-3">
|
||||
<div className="box-shadow-down-1 image-box">
|
||||
<img
|
||||
|
||||
Reference in New Issue
Block a user