From 2b5c66478ec236ce932dbcd108305534d90a1453 Mon Sep 17 00:00:00 2001 From: Arunachalam Date: Fri, 28 May 2021 14:46:26 +0530 Subject: [PATCH] Add ECM Field to status program --- .../pyspark_observation_status_batch.py | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/observations/pyspark_observation_status_batch.py b/observations/pyspark_observation_status_batch.py index 616bb4e..b495a8b 100644 --- a/observations/pyspark_observation_status_batch.py +++ b/observations/pyspark_observation_status_batch.py @@ -123,7 +123,20 @@ def convert_to_row(d: dict) -> Row: "appInformation": {"appName": 1}, "isAPrivateProgram": 1, "isRubricDriven":1, - "criteriaLevelReport":1 + "criteriaLevelReport":1, + "ecm_marked_na": { + "$reduce": { + "input": "$evidencesStatus", + "initialValue": "", + "in": { + "$cond": [ + {"$eq": [{"$toBool":"$$this.notApplicable"},True]}, + {"$concat" : ["$$value", "$$this.name", ";"]}, + "$$value" + ] + } + } + } } }] ) @@ -152,7 +165,8 @@ def convert_to_row(d: dict) -> Row: StructType([StructField('appName', StringType(), True)]) ), StructField('isRubricDriven',StringType(),True), - StructField('criteriaLevelReport',StringType(),True) + StructField('criteriaLevelReport',StringType(),True), + StructField('ecm_marked_na', StringType(), True) ] ) @@ -246,7 +260,8 @@ def convert_to_row(d: dict) -> Row: obs_sub_df1["programExternalId"].alias("program_externalId"), obs_sub_df1["app_name"], obs_sub_df1["private_program"], - obs_sub_df1["solution_type"] + obs_sub_df1["solution_type"], + obs_sub_df1["ecm_marked_na"] ) obs_sub_cursorMongo.close()