|
@@ -101,8 +101,13 @@ def enrich_after_upsert!(table:, council_reference:, address:)
|
|
|
if resp["ok"]
|
|
if resp["ok"]
|
|
|
pid = (resp["pid"] || "").to_s
|
|
pid = (resp["pid"] || "").to_s
|
|
|
title = (resp["title_id"] || "").to_s
|
|
title = (resp["title_id"] || "").to_s
|
|
|
- upd = DB.client.prepare("UPDATE `#{esc}` SET property_id = COALESCE(NULLIF(?,’’), property_id), title_reference = COALESCE(NULLIF(?,’’), title_reference) WHERE council_reference = ? AND address = ?")
|
|
|
|
|
- upd.execute(pid, title, council_reference, address)
|
|
|
|
|
|
|
+ upd = DB.client.prepare(
|
|
|
|
|
+ "UPDATE `#{esc}` SET " \
|
|
|
|
|
+ "property_id = IF(? <> ‘’, ?, property_id), " \
|
|
|
|
|
+ "title_reference = IF(? <> ‘’, ?, title_reference) " \
|
|
|
|
|
+ "WHERE council_reference = ? AND address = ?"
|
|
|
|
|
+ )
|
|
|
|
|
+ upd.execute(pid, pid, title, title, council_reference, address)
|
|
|
Log.debug "enrich", "lookup ok #{table} #{council_reference} pid=#{pid} title=#{title}"
|
|
Log.debug "enrich", "lookup ok #{table} #{council_reference} pid=#{pid} title=#{title}"
|
|
|
else
|
|
else
|
|
|
Log.warn "enrich", "lookup error #{table} #{council_reference}: #{resp["error"]}"
|
|
Log.warn "enrich", "lookup error #{table} #{council_reference}: #{resp["error"]}"
|