Skip to content

Commit e3621b6

Browse files
authored
ingestion of test/sandbox courses (#2224)
* adding test mode field * adding filters to pull in test_mode resources * fixes * update specs * adding test * adding test * adding test for etl loading of test courses * making sure test mode content files are embedded * fixing tests * fixing tests * ensure test mode content files are indexed * fixing test * test fix * mocking deindex_items * making sure all etl commands process test_mode appropriately * making run filters look for published | test_mode=True * fixing migration * fetching all courses for mitxonline and moving published logic to transform_course * fixing tests * fixing flag for published programs and fixing tests * fixing cases where fields dont exist * fixing filter for fetch courses by id * fixing published conditional * fixing test
1 parent cf4d909 commit e3621b6

28 files changed

+421
-30
lines changed

frontends/api/src/generated/v0/api.ts

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontends/api/src/generated/v1/api.ts

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

learning_resources/etl/edx_shared.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from tarfile import ReadError
77
from tempfile import TemporaryDirectory
88

9+
from django.db.models import Q
10+
911
from learning_resources.etl.constants import ETLSource
1012
from learning_resources.etl.loaders import load_content_files
1113
from learning_resources.etl.utils import (
@@ -109,12 +111,18 @@ def sync_edx_course_files(
109111
matches = re.search(rf"{s3_prefix}/(.+)\.tar\.gz$", key)
110112
run_id = matches.group(1).split("/")[-1]
111113
log.info("Run is is %s", run_id)
112-
runs = LearningResourceRun.objects.filter(
113-
learning_resource__etl_source=etl_source,
114-
learning_resource_id__in=ids,
115-
learning_resource__published=True,
116-
published=True,
114+
runs = (
115+
LearningResourceRun.objects.filter(
116+
learning_resource__etl_source=etl_source,
117+
learning_resource_id__in=ids,
118+
)
119+
.filter(Q(published=True) | Q(learning_resource__test_mode=True))
120+
.filter(
121+
Q(learning_resource__published=True)
122+
| Q(learning_resource__test_mode=True)
123+
)
117124
)
125+
118126
if etl_source == ETLSource.mit_edx.name:
119127
# Additional processing of run ids and tarfile names,
120128
# because edx data is structured differently
@@ -142,7 +150,11 @@ def sync_edx_course_files(
142150
resource = run.learning_resource
143151
if run != (
144152
resource.next_run
145-
or resource.runs.filter(published=True).order_by("-start_date").first()
153+
or resource.runs.filter(
154+
Q(published=True) | Q(learning_resource__test_mode=True)
155+
)
156+
.order_by("-start_date")
157+
.first()
146158
):
147159
log.info("Skipping %s, not the next / most recent run", run.run_id)
148160
continue

0 commit comments

Comments
 (0)