Skip to content

Conversation

@mbertrand
Copy link
Member

@mbertrand mbertrand commented Sep 10, 2024

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/5133
Closes https://github.com/mitodl/hq/issues/5132

Description (What does it do?)

Adds license_cc (default False) and continuing_ed_credits (defaultNone) fields to LearningResource and updates relevant ETL pipelines to populate those fields.

How can this be tested?

Set OCW_*, SEE_* and XPRO_* env settings to the same as RC.

Run docker compose up. The new migration should run and set license_cc to True for OCW resources. Everything else will have the default False.

Run the following, when it's done, many of the ingested courses should have a non-null continuing_ed_credits numerical value.

./manage.py backpopulate_sloan_data
./manage.py backpopulate_xpro_data

Run the following, then check that the course has license_cc=True:

./manage.py backpopulate_ocw_data --course-name 14-44-energy-economics-spring-2007 --skip-contentfiles

@mbertrand mbertrand changed the title license_cc and contiuing_ed_credits fields license_cc and continuing_ed_credits fields Sep 10, 2024
@shanbady shanbady self-assigned this Sep 11, 2024
@shanbady shanbady self-requested a review September 11, 2024 13:30
Copy link
Contributor

@shanbady shanbady left a comment

Choose a reason for hiding this comment

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

Looks good. left a minor comment about the spec mismatch which I dont think has any functional consequence.

* @type {string}
* @memberof ProgramResource
*/
continuing_ed_credits?: string | null
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems like the generated spec things this should be string/null but on the LearningResource this is a decimalfield. Probably won't cause outward issues but making sure this is expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like this is a consequence of the field being of type Decimal, the same occurs with the prices field:

   * @type {Array<string>}
   * @memberof CourseResource
   */
  prices: Array<string>

Copy link
Member Author

Choose a reason for hiding this comment

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

DRF coerces decimal values to string by default. If we ever decide to change this, we can set COERCE_DECIMAL_TO_STRING=False

https://www.django-rest-framework.org/api-guide/fields/#decimalfield

coerce_to_string Set to True if string values should be returned for the representation, or False if Decimal objects should be returned. Defaults to the same value as the COERCE_DECIMAL_TO_STRING settings key, which will be True unless overridden. If Decimal objects are returned by the serializer, then the final output format will be determined by the renderer. Note that setting localize will force the value to True.

@mbertrand mbertrand merged commit 6afa145 into main Sep 11, 2024
@odlbot odlbot mentioned this pull request Sep 12, 2024
17 tasks
@rhysyngsun rhysyngsun deleted the mb/license_credits branch February 7, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants