Skip to content

Conversation

@mbertrand
Copy link
Member

@mbertrand mbertrand commented Jun 14, 2024

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/4585

Description (What does it do?)

  • Modifies the calculation of LearningResource.prices to return the prices of the resource's next run (if any).
  • Adds a line to the etl.loaders.load_run function to sort the list of prices before saving.

How can this be tested?

LearningResourceRun.prices sort

  • On the main branch, if you haven't already, run backpopulate_mit_edx_data (you will need the EDX_API_ settings from heroku). Check that the following returns some unsorted run prices:
    from learning_resources.models import LearningResourceRun
    for run in LearningResourceRun.objects.filter(published=True, prices__isnull=False):
        if run.prices != sorted(run.prices):
            print(run.id, run.learning_resource.etl_source, run.learning_resource.resource_type, run.prices)
  • Switch to this branch, run backpopulate_mit_edx_data again. This time, if you run the above code, no runs should be returned

LearningResource.prices

Go to http://localhost:8063/api/v1/courses and check that the resource prices field is the same as for the next run of that resource.

Additional Context

This PR won't update existing runs with unsorted price, but the ETL pipelines that will do so run every day.

@mbertrand mbertrand added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Jun 14, 2024
@jkachel jkachel self-requested a review June 17, 2024 15:28
@jkachel jkachel self-assigned this Jun 17, 2024
@mbertrand mbertrand force-pushed the mb/pricefix branch 2 times, most recently from 887635f to 233a514 Compare June 17, 2024 16:39
Copy link
Contributor

@jkachel jkachel left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.

3 participants