From 39ccb8d1f2ace0f483edbf97ea0b60a5502d4e7f Mon Sep 17 00:00:00 2001 From: Olivier Leger Date: Thu, 19 Sep 2024 18:09:16 -0400 Subject: [PATCH] fix bug when supplementalDetails is empty if qpath is not present --- kobo/apps/subsequences/api_view.py | 2 +- kobo/apps/subsequences/utils/__init__.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kobo/apps/subsequences/api_view.py b/kobo/apps/subsequences/api_view.py index d5e806c66b..e744cd7102 100644 --- a/kobo/apps/subsequences/api_view.py +++ b/kobo/apps/subsequences/api_view.py @@ -102,7 +102,7 @@ def get_submission_processing(asset, s_uuid): try: submission_extra = asset.submission_extras.get(submission_uuid=s_uuid) - # TODO delete two lines below when every asset is repopulated with + # TODO delete "if" statement below when every asset is repopulated with # `xpath` instead of `qpath`. if content := get_sanitized_dict_keys( submission_extra.content, asset diff --git a/kobo/apps/subsequences/utils/__init__.py b/kobo/apps/subsequences/utils/__init__.py index ce5f223909..6d69bfcd53 100644 --- a/kobo/apps/subsequences/utils/__init__.py +++ b/kobo/apps/subsequences/utils/__init__.py @@ -212,7 +212,14 @@ def stream_with_extras(submission_stream, asset): val_expanded = val_expanded[0] qual_response['val'] = val_expanded qual_response.update(qual_q) - submission[SUPPLEMENTAL_DETAILS_KEY] = get_sanitized_dict_keys( + + # Remove `qpath` if present + if sanitized_suppl_details := get_sanitized_dict_keys( all_supplemental_details, asset - ) + ): + all_supplemental_details = sanitized_suppl_details + + submission[SUPPLEMENTAL_DETAILS_KEY] = all_supplemental_details + + yield submission