From 09f728ba1294c645d6d4e4339cbf4afd14870cd8 Mon Sep 17 00:00:00 2001 From: nazarfil Date: Tue, 31 Dec 2024 09:03:35 +0100 Subject: [PATCH] move out fields split --- openhexa/toolbox/dhis2/dhis2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openhexa/toolbox/dhis2/dhis2.py b/openhexa/toolbox/dhis2/dhis2.py index c6ef1b6..2da3fc4 100644 --- a/openhexa/toolbox/dhis2/dhis2.py +++ b/openhexa/toolbox/dhis2/dhis2.py @@ -66,8 +66,9 @@ def organisation_unit_levels(self, fields: str = "id,name,level") -> List[dict]: params = {"fields": fields} r = self.client.api.get("filledOrganisationUnitLevels", params=params) levels = [] + fields_list = fields.split(",") for level in r: - levels.append({k: v for k, v in level.items() if k in fields.split(",")}) + levels.append({k: v for k, v in level.items() if k in fields_list}) return levels def organisation_units(self, fields: str = "id,name,level,path,geometry", filter: str = None) -> List[dict]: