diff --git a/plugins/wfp/management/commands/nigeria/Under5.py b/plugins/wfp/management/commands/nigeria/Under5.py index fe4c69d9c3..9cdf79fd07 100644 --- a/plugins/wfp/management/commands/nigeria/Under5.py +++ b/plugins/wfp/management/commands/nigeria/Under5.py @@ -110,13 +110,11 @@ def group_visit_by_entity(self, entities): ) def run(self): - children_type = ["ng_-_tsfp_child_3", "ng_-_otp_child_3"] - entity_type = ETL(children_type) - type = EntityType.objects.get(code="ng_-_tsfp_child_3") + entity_type = ETL(["child_under_5_3"]) account = entity_type.account_related_to_entity_type() beneficiaries = entity_type.retrieve_entities() - logger.info(f"Instances linked to Child Under 5 program: {beneficiaries.count()} for {type.name} on {account}") + logger.info(f"Instances linked to Child Under 5 program: {beneficiaries.count()} for {account}") entities = sorted(list(beneficiaries), key=itemgetter("entity_id")) existing_beneficiaries = ETL().existing_beneficiaries() instances = self.group_visit_by_entity(entities) diff --git a/plugins/wfp/management/commands/south_sudan/Pbwg.py b/plugins/wfp/management/commands/south_sudan/Pbwg.py index a36bf3a4a2..2a6147d0c8 100644 --- a/plugins/wfp/management/commands/south_sudan/Pbwg.py +++ b/plugins/wfp/management/commands/south_sudan/Pbwg.py @@ -13,7 +13,7 @@ def run(self): entity_type = ETL(["pbwg_1"]) account = entity_type.account_related_to_entity_type() beneficiaries = entity_type.retrieve_entities() - logger.info(f"Instances linked to PBWG program: {beneficiaries.count()}") + logger.info(f"Instances linked to PBWG program: {beneficiaries.count()} for {account}") entities = sorted(list(beneficiaries), key=itemgetter("entity_id")) existing_beneficiaries = ETL().existing_beneficiaries() instances = self.group_visit_by_entity(entities) diff --git a/plugins/wfp/management/commands/south_sudan/Under5.py b/plugins/wfp/management/commands/south_sudan/Under5.py index 826e2ac19b..05dc1ce4b3 100644 --- a/plugins/wfp/management/commands/south_sudan/Under5.py +++ b/plugins/wfp/management/commands/south_sudan/Under5.py @@ -140,7 +140,7 @@ def run(self): entity_type = ETL(["child_under_5_1"]) account = entity_type.account_related_to_entity_type() beneficiaries = entity_type.retrieve_entities() - logger.info(f"Instances linked to Child Under 5 program: {beneficiaries.count()}") + logger.info(f"Instances linked to Child Under 5 program: {beneficiaries.count()} for {account}") entities = sorted(list(beneficiaries), key=itemgetter("entity_id")) existing_beneficiaries = ETL().existing_beneficiaries() instances = self.group_visit_by_entity(entities) diff --git a/plugins/wfp/tasks.py b/plugins/wfp/tasks.py index e6ca96e572..5e55a33083 100644 --- a/plugins/wfp/tasks.py +++ b/plugins/wfp/tasks.py @@ -14,7 +14,8 @@ def etl_ng(): """Extract beneficiary data from Iaso tables and store them in the format expected by existing tableau dashboards""" logger.info("Starting ETL for Nigeria") - account = ETL(["ng_-_tsfp_child_3", "ng_-_otp_child_3"]).account_related_to_entity_type() + account = ETL(["child_under_5_3"]).account_related_to_entity_type() + Beneficiary.objects.all().filter(account=account).delete() NG_Under5().run() logger.info( @@ -27,6 +28,7 @@ def etl_ng(): def etl_ssd(): logger.info("Starting ETL for South Sudan") child_account = ETL(["child_under_5_1"]).account_related_to_entity_type() + Beneficiary.objects.all().filter(account=child_account).delete() Under5().run() logger.info( @@ -35,6 +37,7 @@ def etl_ssd(): ETL().journey_with_visit_and_steps_per_visit(child_account, "U5") pbwg_account = ETL(["pbwg_1"]).account_related_to_entity_type() + Beneficiary.objects.all().filter(account=pbwg_account).delete() PBWG().run() logger.info( f"----------------------------- Aggregating PBWG journey for {pbwg_account} per org unit, admission and period(month and year) -----------------------------"