diff --git a/pipeline/scripts/sync_typesense.py b/pipeline/scripts/sync_typesense.py index cce0660..30194c5 100644 --- a/pipeline/scripts/sync_typesense.py +++ b/pipeline/scripts/sync_typesense.py @@ -33,7 +33,7 @@ COLLECTION_SCHEMA = { {"name": "headteacher_name", "type": "string", "optional": True}, {"name": "rwm_expected_pct", "type": "float", "optional": True}, {"name": "progress_8_score", "type": "float", "optional": True}, - {"name": "total_pupils", "type": "int32", "optional": True}, + {"name": "total_pupils", "type": "int32"}, ], "default_sorting_field": "total_pupils", } @@ -52,8 +52,8 @@ QUERY_BASE = """ l.postcode, s.headteacher_name, s.total_pupils, - ST_Y(l.geom) as lat, - ST_X(l.geom) as lng + l.latitude as lat, + l.longitude as lng FROM marts.dim_school s LEFT JOIN marts.dim_location l ON s.urn = l.urn """ diff --git a/pipeline/transform/models/marts/dim_location.sql b/pipeline/transform/models/marts/dim_location.sql index 11fc951..be285a1 100644 --- a/pipeline/transform/models/marts/dim_location.sql +++ b/pipeline/transform/models/marts/dim_location.sql @@ -19,6 +19,16 @@ select when s.easting is not null and s.northing is not null then ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326) else null - end as geom + end as geom, + case + when s.easting is not null and s.northing is not null + then ST_Y(ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326)) + else null + end as latitude, + case + when s.easting is not null and s.northing is not null + then ST_X(ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326)) + else null + end as longitude from {{ ref('stg_gias_establishments') }} s where s.status = 'Open'