Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLFM-8788: Includes passing record createdOn and backfill #69

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/scripts/glue_jobs/certified_quiz_question_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def execute(self, dynamic_frame):
("correction.questionIndex", "int", "question_index", "bigint"),
("correction.isCorrect", "boolean", "is_correct", "boolean"),
("snapshot_date", "string", "snapshot_date", "date"),
("created_on", "bigint", "created_on", "timestamp")
]
)
return mapped_output_frame
Expand All @@ -56,6 +57,19 @@ def transform(dynamic_record):
dynamic_record["corrections"] = correctionInfo
# This is the partition date
dynamic_record[PARTITION_KEY] = Utils.ms_to_partition_date(dynamic_record["snapshotTimestamp"])

# The createdOn field was introduced in https://sagebionetworks.jira.com/browse/PLFM-8788
# and need default values for older records. We use the deprecated "passedOn" that was actually
# matching the creation date of the record and was never used to indicate when the quiz was passed
if "createdOn" not in dynamic_record["snapshot"] or dynamic_record["snapshot"]["createdOn"] is None:
createdOn = dynamic_record["snapshot"]["passedOn"]
else:
createdOn = dynamic_record["snapshot"]["createdOn"]

# We cannot change nested fields (e.g. dynamic_record["snaphost"]["createdOn"] = createdOn does not work) in the dynamic_record
# without transforming it to a data frame so we just use a new column
dynamic_record["created_on"] = createdOn

return dynamic_record


Expand Down
9 changes: 8 additions & 1 deletion src/scripts/glue_jobs/certified_quiz_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def transform(dynamic_record):
if "certified" not in dynamic_record or dynamic_record["certified"] is None:
dynamic_record["certified"] = dynamic_record["passed"]

# The createdOn field was introduced in https://sagebionetworks.jira.com/browse/PLFM-8788
# and need default values for older records. We use the deprecated "passedOn" that was actually
# matching the creation date of the record and was never used to indicate when the quiz was passed
if "created_on" not in dynamic_record or dynamic_record["created_on"] is None:
dynamic_record["created_on"] = dynamic_record["passed_on"]

return dynamic_record


Expand All @@ -49,6 +55,7 @@ def transform(dynamic_record):
("snapshot.passedOn", "bigint", "passed_on", "timestamp"),
("snapshot.revoked", "boolean", "revoked", "boolean"),
("snapshot.revokedOn", "bigint", "revoked_on", "timestamp"),
("snapshot.certified", "boolean", "certified", "boolean")
("snapshot.certified", "boolean", "certified", "boolean"),
("snapshot.createdOn", "bigint", "created_on", "timestamp")
]
certified_quiz_snapshots = CertifiedQuizSnapshots(mapping_list, PARTITION_KEY)
Loading