Skip to content

Commit 275b035

Browse files
committed
Update the pipeline to address - animals_slaughtered is null/0 or carcass_weight is null/0, then a percentage_kcals of 0 is not meaningful see HEA-957
1 parent e9a70ce commit 275b035

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pipelines/assets/livelihood_activity.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,18 @@ def get_instances_from_dataframe(
913913
# to the list, provided that it has at least one Livelihood Activity where there is some income,
914914
# expediture or consumption. This excludes empty activities that only contain attributes for,
915915
# for example, 'type_of_milk_sold_or_other_uses'.
916+
# For MeatProduction, if animals_slaughtered is null/0 or carcass_weight is null/0, then a
917+
# percentage_kcals of 0 is not meaningful (it results from the BSS formula evaluating to 0
918+
# because there are no animals or no carcass weight). Set it to None so that the activity is
919+
# treated as empty and not saved to the database.
920+
if livelihood_strategy and livelihood_strategy["strategy_type"] == "MeatProduction":
921+
for livelihood_activity in livelihood_activities_for_strategy:
922+
if (
923+
not livelihood_activity.get("animals_slaughtered")
924+
or not livelihood_activity.get("carcass_weight")
925+
) and livelihood_activity.get("percentage_kcals") == 0:
926+
livelihood_activity["percentage_kcals"] = None
927+
916928
# Also ignore any livelihood activities that don't have a Wealth Category component to the Wealth Group
917929
# natural key. These are from blank columns between Wealth Category groups in the BSS, which sometimes
918930
# contain data where values or formulae have been copied across all the columns in a row.

0 commit comments

Comments
 (0)