Skip to content

Commit

Permalink
Fixed geo location check for the facility update
Browse files Browse the repository at this point in the history
  • Loading branch information
dborowiecki committed Jul 2, 2024
1 parent 7e19dda commit 488a2b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _create_new_facilities(self, facilities):
col(f"facilities.code"),
col("municipality.id"),
col("facility_type.id"),
lit({}),
lit('{}'),
col("is_operational"),
lit(True)
),
Expand Down Expand Up @@ -382,7 +382,7 @@ def compare_for_any_change(df, col1, col2):

# Select the original JSON payloads and the any_change flag
return df.select(
"payload", "existing_facilities.id", "oldPayload", change_column, *changes2
"payload", "existing_facilities.id", "oldPayload", change_column
)


Expand Down
7 changes: 5 additions & 2 deletions sigeca_data_import_microservice/app/domain/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def get_all(self):

class FacilityResourceRepository(BaseResourceRepository):
def get_all(self):
query = """(SELECT f.*,
# Geo zone parent is taken because by API endpoint assigns the geo location to ward
query = """(SELECT f.id, f.name,f.code,f.active,f.enabled,f.typeid,gz2.id as"geographiczoneid",
(CASE
WHEN count(p.code) = 0 THEN '{}'::jsonb
ELSE jsonb_object_agg(
Expand All @@ -28,7 +29,9 @@ def get_all(self):
FROM referencedata.facilities f
LEFT JOIN referencedata.supported_programs sp ON sp.facilityid = f.id
LEFT JOIN referencedata.programs p ON sp.programid = p.id
GROUP BY f.id
LEFT JOIN referencedata.geographic_zones gz ON gz.id = f.geographiczoneid
LEFT JOIN referencedata.geographic_zones gz2 ON gz2.id = gz.parentid
GROUP BY f.id, gz2.id
) AS facilities"""
return self.jdbc_reader.read_data(query)

Expand Down

0 comments on commit 488a2b9

Please sign in to comment.