Skip to content

Conversation

mbertrand
Copy link
Member

@mbertrand mbertrand commented Oct 8, 2025

What are the relevant tickets?

Description (What does it do?)

Replaces LearningResource.next_run with LearningResource.best_run and changes the criteria for selecting that run. This way, an enrollable run that is currently ongoing (start date in the past, end date in the future) should be selected instead of the next enrollable run with a future start date.

How can this be tested?

  • Assign XPRO_* env variables in your backend.local.env file
  • Run ./manage.py backpopulate_xpro_data
  • Wait for the search index to finish updating.
  • Search for "Leading Teams" - https://open.odl.local:8063/search?q=%22Leading+Teams%22
  • The result card for that course should show "Starts <today's date>", and not "February 9, 2026" (which is the date shown on RC and prod, and locally if you run the above command on the main branch instead)
  • You can repeat this for other courses mentioned in the issue.

Screenshots

This branch:

Screenshot 2025-10-09 083704

Main branch, RC/Prod:

Screenshot 2025-10-09 083720

@mbertrand mbertrand added Work in Progress Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Oct 8, 2025
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

👍

published_runs = self.runs.filter(published=True)
now = now_in_utc()
# Find the most recent run with a currently active enrollment period
current_run = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be best_run? It seems to start w/ current run, but fallback to future or older.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will rename to best_lr_run to avoid any confusion with the property name itself.

)
if best_run:
now = now_in_utc()
if resource.published:
Copy link
Contributor

Choose a reason for hiding this comment

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

I have about 3k resources locally from ocw, xpro, mitxonline, see, and mit_edx. (I think thats all of them?) All published resources have a best_run 👍, but some unpublished ones don't.

If somehow a published resource had no best run, we get errors below, right? Should we keep the best_run check here? What happens if errors below occur? Just that 1 resource fails ETL, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That should only happen if a resource has no published runs at all, in which case the resource itself shouldn't be published. I'll add the best_run check back just in case.

Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

👍 Thanks for the explanation!

@mbertrand mbertrand merged commit 32c4829 into main Oct 10, 2025
13 checks passed
@mbertrand mbertrand deleted the mb/best_run branch October 10, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants