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

fix: use correct course_key in case of a key_for_rerun in RCM #4411

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

Ali-D-Akbar
Copy link
Contributor

PROD-4133

Updates the logic behind bringing the courses from studio in case a course is created in Studio and not in Discovery. Previous logic used to create a course_run from Studio into Discovery with whatever was present in the key. In case a course has a value in key_for_reruns, it used to assign those course_runs to the key equal to key_for_reruns.

Now, it finds if a course has a key_for_reruns, it will assign this course_run to the correct course that has the custom key_for_reruns value.

@Ali-D-Akbar Ali-D-Akbar force-pushed the aakbar/PROD-4133 branch 3 times, most recently from 918f5d3 to 002081d Compare August 16, 2024 21:13
@@ -202,6 +202,8 @@ def create_course_run(self, course, body):
def get_or_create_course(self, body):
course_run_key = CourseKey.from_string(body['id'])
course_key = self.get_course_key_from_course_run_key(course_run_key)
course_key = (Course.objects.filter(key_for_reruns=course_key).values_list('key', flat=True).first() or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: There should be a comment explaining this scenario in the code. Or better, have an internal or util function to return the course key that considers both scenarios.

datum = mock_data.COURSES_API_BODY_ORIGINAL
self.mock_api([datum])
course_type = CourseType.objects.get(slug=CourseType.AUDIT)
course_key = '{org}+{number}'.format(org=datum['org'], number=datum['number'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use f-string, no need to use format anymore.

course_type = CourseType.objects.get(slug=CourseType.AUDIT)
course_key = '{org}+{number}'.format(org=datum['org'], number=datum['number'])
course_key_with_key_for_rerun = 'test+key_for_rerun'
Course.objects.create(partner=self.partner, key=course_key, title='Title', type=course_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the first course be created here? Shouldn't only the course with key_for_reruns be created only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scenario we're testing should have a courseA and courseB having key_for_reruns = courseA.key

@Ali-D-Akbar Ali-D-Akbar force-pushed the aakbar/PROD-4133 branch 3 times, most recently from f28d391 to 35d76af Compare August 19, 2024 09:30
@Ali-D-Akbar Ali-D-Akbar merged commit 1ab24d6 into master Aug 20, 2024
25 of 26 checks passed
@Ali-D-Akbar Ali-D-Akbar deleted the aakbar/PROD-4133 branch August 20, 2024 12:59
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.

3 participants