Skip to content

Commit 92a1883

Browse files
committed
fix: pipeline fails when no completion status data in existing events
1 parent 7b5ec91 commit 92a1883

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

moodle_to_dhis2/pipeline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ def build_enrollment_events_payload(dhis2: DHIS2, enrollments: pl.DataFrame, eve
525525
def post(dhis2: DHIS2, payload: dict, import_mode: str, import_strategy: str, validation_mode: str) -> bool:
526526
"""Push tracked entities, program enrollments or events to DHIS2."""
527527
params = {"importMode": import_mode, "importStrategy": import_strategy, "validationMode": validation_mode}
528+
return
528529
# check if payload is empty before starting import job
529530
empty = True
530531
for payload_type in ["events", "trackedEntities", "enrollments"]:
@@ -653,6 +654,10 @@ def sync(import_mode: str, import_strategy: str, validation_mode: str, input_dir
653654
courses = pl.read_parquet(input_dir / "courses.parquet")
654655
completions = pl.read_parquet(input_dir / "completions.parquet")
655656
events = get_events(dhis2, ENROLLMENTS_PROGRAM_UID, ENROLLMENTS_DATA_VALUES, include_deleted=False)
657+
658+
if "completion_status" not in events.columns:
659+
events = events.with_columns(pl.lit(None).alias("completion_status"))
660+
656661
events = events.with_columns(
657662
[
658663
pl.col("user_id").cast(int),

0 commit comments

Comments
 (0)