Skip to content

Commit

Permalink
feat: Source price from content_price for fixed_price_usd in CatalogW…
Browse files Browse the repository at this point in the history
…orkbookView
  • Loading branch information
brobro10000 committed Sep 30, 2024
1 parent 4a20261 commit ef1cb9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions enterprise_catalog/apps/api/v1/export_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'End Date',
'Verified Upgrade Deadline',
'Enroll-by Date',
'Price',
'Min Effort',
'Max Effort',
'Length',
Expand Down Expand Up @@ -210,7 +211,10 @@ def course_hit_to_row(hit):

csv_row.append(hit.get('level_type'))

csv_row.append(hit.get('first_enrollable_paid_seat_price'))
if content_price := advertised_course_run.get('content_price'):
content_price = math.trunc(float(content_price))
csv_row.append(content_price)

csv_row.append(hit.get('language'))
csv_row.append(', '.join(hit.get('transcript_languages', [])))
csv_row.append(hit.get('marketing_url'))
Expand Down Expand Up @@ -283,8 +287,12 @@ def exec_ed_course_to_row(hit):
adv_course_run = hit.get('advertised_course_run', {})
key = adv_course_run.get('key')

price = float(hit['entitlements'][0]['price'])
csv_row.append(math.trunc(price))
empty_advertised_course_run = {}
advertised_course_run = hit.get('advertised_course_run', empty_advertised_course_run)
if content_price := advertised_course_run.get('content_price'):
content_price = math.trunc(float(content_price))
csv_row.append(content_price)

csv_row.append(hit.get('language'))
csv_row.append(', '.join(hit.get('transcript_languages', [])))
csv_row.append(hit.get('marketing_url'))
Expand Down Expand Up @@ -354,6 +362,10 @@ def course_run_to_row(hit, course_run):
if enroll_by := course_run.get('enroll_by', None):
enroll_by = datetime.datetime.fromtimestamp(enroll_by).strftime(DATE_FORMAT)
csv_row.append(enroll_by)

if content_price := course_run.get('content_price'):
content_price = math.trunc(float(content_price))
csv_row.append(content_price)

# Min Effort
csv_row.append(course_run.get('min_effort'))
Expand Down
3 changes: 2 additions & 1 deletion enterprise_catalog/apps/api/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ class EnterpriseCatalogCsvDataViewTests(APITestMixin):
'max_effort': 10,
'min_effort': 1,
'weeks_to_complete': 1,
'content_price': 100,
},
'outcome': '<p>learn</p>',
'prerequisites_raw': '<p>interest</p>',
Expand Down Expand Up @@ -777,8 +778,8 @@ def _get_contains_content_base_url(self):
def _get_mock_algolia_hits_with_missing_values(self):
mock_hits_missing_values = copy.deepcopy(self.mock_algolia_hits)
mock_hits_missing_values['hits'][0]['advertised_course_run'].pop('upgrade_deadline')
mock_hits_missing_values['hits'][0]['advertised_course_run'].pop('content_price')
mock_hits_missing_values['hits'][0].pop('marketing_url')
mock_hits_missing_values['hits'][0].pop('first_enrollable_paid_seat_price')
mock_hits_missing_values['hits'][0]['advertised_course_run']['end'] = None
return mock_hits_missing_values

Expand Down

0 comments on commit ef1cb9c

Please sign in to comment.