fix: Include start/end dates for external course run#4658
fix: Include start/end dates for external course run#4658UsamaSadiq merged 1 commit intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @rjv31! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| 'start': self.get_formatted_datetime_string(f"{course_run_data['start_date']} {course_run_data['start_time']}"), | ||
| 'end': self.get_formatted_datetime_string(f"{course_run_data['end_date']} {course_run_data['end_time']}"), |
There was a problem hiding this comment.
Please add or update related csv_loader tests.
There was a problem hiding this comment.
added csv_loader tests
2fcae65 to
594d1ba
Compare
9301d01 to
5dce002
Compare
| 'enrollment_end': serialize_datetime(run.enrollment_end), | ||
| } | ||
|
|
||
| if add_schedule or add_enrollment_dates: |
There was a problem hiding this comment.
@rjv31 What is the significance of this line?
There was a problem hiding this comment.
Hi @ankit-sonata, This condition ensures we only add schedule or enrollment dates when required. it prevents inserting empty/unnecessary data and keeps the output clean. it also supports our recent change of including start/end dates by making sure they are added only when needed.
| # It is better to keep the flow consistent across places. | ||
| # Allow sending enrollment start and end dates as part of Update only. | ||
| data['schedule'] = { | ||
| # Using setdefault + update avoids overwriting and prevents KeyErrors. |
There was a problem hiding this comment.
@rjv31 Why are you making unnecessary changes?
There was a problem hiding this comment.
Hi @ankit-sonata, This change wasn't unnecessary - earlier data['schedule'] was being reassigned, which could overwrite existing values. with setdefault + update, we make sure that existing schedule data (like start/end) is preserved while still adding enrollment dates, and it also avoids possible KeyErrors.
| mock_logger.info.assert_called_with( | ||
| f'Enrollment information added to data {output_data} for course run {run.key}' | ||
| ) | ||
| mock_logger.info.assert_called() |
There was a problem hiding this comment.
Why did you update the old assers
There was a problem hiding this comment.
Hi @ankit-sonata, The log text changed because of our recent updates (extra fields are now added to data like start and end). Instead of matching the entire log line exactly, I updated the test to only check that logging happened and that the important part of the message is present. This way the test wont keep breaking on small formatting changes, but still verifies the log is correct.
|
Rebase you branch with main and make sure the build should pass. |
b545119 to
45b58fd
Compare
|
@rjv31 The build is getting failed, it should pass. |
62b2f60 to
828c0db
Compare
d2ec251 to
24f74ba
Compare
24f74ba to
b648420
Compare
b648420 to
a4a8f60
Compare
|
@hamza-56 could you please review/merge the PR |
|
@mphilbrick211 could you please help review/merge this PR |
|
@DawoudSheraz @ankit-sonata - hi there! Is one of you able to review / merge this for us? |
Neither of us has write permissions. @openedx/course-discovery-maintainers can help with this. |
|
@mphilbrick211 @openedx/course-discovery-maintainers could anyone please check and help review/merge this PR |
|
@openedx/committers-course-discovery sorry, we pinged the wrong group earlier. Would one of you folks mind reviewing/approving for us? This would help 2u solve some operational pain around external course metadata management, and its scope is pretty specific. Thanks in advance! |
|
@mphilbrick211 here is another PR that the 2U team is waiting on. Thanks! |
|
@hamza-56 @taimoor-ahmed-1 @bmtcril would one of you be able to please review / merge this for us? The 2U team is eager to get this through. Thanks! |
|
@UsamaSadiq Hi, can you help with the merge here? Hamza is no longer CC and cannot merge the PR. |
This PR addresses the need to ensure that external course runs include their start and end dates when updating via the Studio API.
Ticket - https://2u-internal.atlassian.net/browse/PROD-4408
Key Changes:
Introduced is_external_course property on the Course model to determine external product types.
Updated generate_data_for_studio_api:
start and end dates are now included when either creating the course run or when the course is external.
Enrollment start/end dates remain update-only, consistent with current API behavior.
Refactored make_studio_data in test suite to merge schedule fields when both start/end and enrollment_start/end are present.
Added unit tests to verify:
Inclusion of start/end for external vs. non-external courses.
Correct behavior on create vs. update operations.
This ensures Studio receives the appropriate scheduling metadata for external products, avoiding downstream issues related to incomplete data.