Skip to content

Comments

fix: Include start/end dates for external course run#4658

Merged
UsamaSadiq merged 1 commit intoopenedx:masterfrom
rjv31:PROD-4408/fix_start_date_updation
Sep 16, 2025
Merged

fix: Include start/end dates for external course run#4658
UsamaSadiq merged 1 commit intoopenedx:masterfrom
rjv31:PROD-4408/fix_start_date_updation

Conversation

@rjv31
Copy link
Contributor

@rjv31 rjv31 commented Aug 6, 2025

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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 6, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @rjv31!

This repository is currently maintained by @openedx/2u-phoenix.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Submit a signed contributor agreement (CLA)

⚠️ We ask all contributors to the Open edX project to submit a signed contributor agreement or indicate their institutional affiliation.
Please see the CONTRIBUTING file for more information.

If you've signed an agreement in the past, you may need to re-sign.
See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed.
After this time, you can re-run the CLA check by adding a comment below that you have signed it.
If the CLA check continues to fail, you can tag the @openedx/cla-problems team in a comment for further assistance.

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Comment on lines 484 to 485
'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']}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add or update related csv_loader tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added csv_loader tests

@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch 4 times, most recently from 2fcae65 to 594d1ba Compare August 8, 2025 18:59
@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch 3 times, most recently from 9301d01 to 5dce002 Compare August 15, 2025 16:43
@rjv31 rjv31 requested a review from DawoudSheraz August 15, 2025 17:03
'enrollment_end': serialize_datetime(run.enrollment_end),
}

if add_schedule or add_enrollment_dates:

Choose a reason for hiding this comment

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

@rjv31 What is the significance of this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Choose a reason for hiding this comment

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

@rjv31 Why are you making unnecessary changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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()

Choose a reason for hiding this comment

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

Why did you update the old assers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@ankit-sonata
Copy link

Rebase you branch with main and make sure the build should pass.

@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch 5 times, most recently from b545119 to 45b58fd Compare August 19, 2025 09:56
@ankit-sonata
Copy link

@rjv31 The build is getting failed, it should pass.

@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch 3 times, most recently from 62b2f60 to 828c0db Compare August 23, 2025 19:29
@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch 8 times, most recently from d2ec251 to 24f74ba Compare August 26, 2025 16:14
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to In Eng Review in Contributions Aug 27, 2025
@rjv31 rjv31 requested a review from ankit-sonata August 28, 2025 17:30
@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch from 24f74ba to b648420 Compare September 1, 2025 11:30
@rjv31 rjv31 force-pushed the PROD-4408/fix_start_date_updation branch from b648420 to a4a8f60 Compare September 1, 2025 11:45
@rjv31
Copy link
Contributor Author

rjv31 commented Sep 2, 2025

@hamza-56 could you please review/merge the PR

@rjv31 rjv31 requested a review from a team September 2, 2025 11:10
@rjv31
Copy link
Contributor Author

rjv31 commented Sep 4, 2025

@mphilbrick211 could you please help review/merge this PR

@mphilbrick211
Copy link

@DawoudSheraz @ankit-sonata - hi there! Is one of you able to review / merge this for us?

@DawoudSheraz
Copy link
Contributor

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

@rjv31
Copy link
Contributor Author

rjv31 commented Sep 8, 2025

@mphilbrick211 @openedx/course-discovery-maintainers could anyone please check and help review/merge this PR

@iloveagent57
Copy link
Contributor

@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!

@julrusak
Copy link

@mphilbrick211 here is another PR that the 2U team is waiting on. Thanks!

@mphilbrick211
Copy link

@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!

@DawoudSheraz DawoudSheraz removed their request for review September 16, 2025 05:36
@DawoudSheraz
Copy link
Contributor

@UsamaSadiq Hi, can you help with the merge here? Hamza is no longer CC and cannot merge the PR.

@UsamaSadiq UsamaSadiq merged commit a4f803b into openedx:master Sep 16, 2025
14 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants