Skip to content

Commit

Permalink
feat: request restricted runs
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Dec 11, 2024
1 parent f43a8d5 commit 79501ab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ Change Log
Unreleased
----------
* Nothing unreleased

1.6.0
-----
* feat: request restricted runs when importing course run data

1.5.2
------------------
-----
* fix: gets custom course URL from DB if possible

1.5.1 – 2024-07-25
Expand Down
2 changes: 1 addition & 1 deletion federated_content_connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
One-line description for README and other doc files.
"""

__version__ = '1.5.2'
__version__ = '1.6.0'
24 changes: 19 additions & 5 deletions federated_content_connector/course_metadata_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ def fetch_courses_details(cls, courserun_locators, api_base_url):
course_uuids = courserun_with_course_uuids.values()
course_uuids_str = ','.join(course_uuids)

query_params = {
'limit': 50,
'include_hidden_course_runs': 1,
'uuids': course_uuids_str,
'include_restricted': 'custom-b2b-enterprise',
}
url_params = urlencode(query_params)
api_url = urljoin(f"{api_base_url}/", f"courses/?{url_params}")
logger.info(f'[{cls.LOG_PREFIX}] Fetching details from discovery. Course UUIDs {course_uuids}.')
api_url = urljoin(
f"{api_base_url}/", f"courses/?limit=50&include_hidden_course_runs=1&uuids={course_uuids_str}"
)
response = cls.get_response_from_api(api_url)
courses_details = response.json()
results = courses_details.get('results', [])
Expand All @@ -131,10 +136,18 @@ def fetch_course_uuids(cls, api_base_url, courserun_locators):
courserun_keys = list(map(str, courserun_locators))
encoded_courserun_keys = ','.join(map(quote_plus, courserun_keys))

logger.info(f'[{cls.LOG_PREFIX}] Fetching uuids for Courseruns {encoded_courserun_keys}')
query_param_str = (
'?limit=50&'
'include_hidden_course_runs=1&'
'include_restricted=custom-b2b-enterprise&'
f'keys={encoded_courserun_keys}'
)
api_url = urljoin(
f"{api_base_url}/", f"course_runs/?limit=50&include_hidden_course_runs=1&keys={encoded_courserun_keys}"
f"{api_base_url}/",
f"course_runs/{query_param_str}"
)

logger.info(f'[{cls.LOG_PREFIX}] Fetching uuids for Courseruns {courserun_keys}')
response = cls.get_response_from_api(api_url)
courses_details = response.json()
results = courses_details.get('results', [])
Expand All @@ -157,6 +170,7 @@ def courses(cls, timestamp):
'timestamp': timestamp,
'limit': 50,
'include_hidden_course_runs': 1,
'include_restricted': 'custom-b2b-enterprise',
}

api_base_url = get_catalog_api_base_url()
Expand Down

0 comments on commit 79501ab

Please sign in to comment.