|
@@ -103,11 +103,15 @@ def enrich_after_upsert!(table:, council_reference:, address:)
|
|
|
title = (resp["title_id"] || "").to_s
|
|
title = (resp["title_id"] || "").to_s
|
|
|
upd = DB.client.prepare(
|
|
upd = DB.client.prepare(
|
|
|
"UPDATE `#{esc}` SET " \
|
|
"UPDATE `#{esc}` SET " \
|
|
|
- "property_id = IF(? <> ‘’, ?, property_id), " \
|
|
|
|
|
- "title_reference = IF(? <> ‘’, ?, title_reference) " \
|
|
|
|
|
|
|
+ "property_id = COALESCE(?, property_id), " \
|
|
|
|
|
+ "title_reference = COALESCE(?, title_reference) " \
|
|
|
"WHERE council_reference = ? AND address = ?"
|
|
"WHERE council_reference = ? AND address = ?"
|
|
|
)
|
|
)
|
|
|
- upd.execute(pid, pid, title, title, council_reference, address)
|
|
|
|
|
|
|
+ upd.execute(
|
|
|
|
|
+ pid.empty? ? nil : pid,
|
|
|
|
|
+ title.empty? ? nil : 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"]}"
|