diff --git a/backend/field_update b/backend/field_update index e4cab08e..b663498b 100644 --- a/backend/field_update +++ b/backend/field_update @@ -194,7 +194,7 @@ class Raw: t1.osm_id, CASE WHEN COUNT(cg.{source_column}) = 0 THEN ARRAY[0]::integer[] - ELSE array_agg(COALESCE(cg.id, 0)) + ELSE array_agg(COALESCE(cg.{source_column}, 0)) END AS aa_fids FROM t1 diff --git a/backend/replication b/backend/replication index 7b2cadd7..e731f9f6 100644 --- a/backend/replication +++ b/backend/replication @@ -534,8 +534,8 @@ def update_country(conn, timestamp, table_name, c_id=None, boundary=None): with conn.cursor() as cur: update_query = f"""WITH t1 AS (SELECT osm_id, ST_Centroid(geom) AS geom FROM {table_name} WHERE "timestamp" >= '{timestamp}'), t2 AS (SELECT t1.osm_id, CASE - WHEN COUNT(cg.id) = 0 THEN ARRAY[0]::integer[] - ELSE array_agg(COALESCE(cg.id, 0)) + WHEN COUNT(cg.cid) = 0 THEN ARRAY[0]::integer[] + ELSE array_agg(COALESCE(cg.cid, 0)) END AS aa_fids FROM t1 LEFT JOIN countries cg ON ST_Intersects(t1.geom, cg.geometry) GROUP BY t1.osm_id) UPDATE {table_name} uw SET country = t2.aa_fids FROM t2 WHERE t2.osm_id = uw.osm_id;""" diff --git a/src/query_builder/builder.py b/src/query_builder/builder.py index f8d09729..65e34947 100644 --- a/src/query_builder/builder.py +++ b/src/query_builder/builder.py @@ -51,7 +51,7 @@ def get_country_id_query(geom_dump): def check_exisiting_country(geom): query = f"""select - b.id::int as fid + b.cid::int as fid from countries b where