deploy Maps v13 update
This commit is contained in:
+15
-3
@@ -802,13 +802,21 @@ def insert_catalogue(run_id: int, query: str, raw_results: list[dict[str, Any]],
|
||||
suppressed_emails = {str(row[0]).lower() for row in conn.execute("SELECT value FROM suppressions WHERE kind='email'")}
|
||||
total = len(mapped)
|
||||
for index, item in enumerate(mapped, 1):
|
||||
item = enrich_place(item)
|
||||
# A hostile or slow public site must not invalidate an otherwise
|
||||
# successful Maps run. Keep the raw listing and mark enrichment as
|
||||
# unknown; it can be rescanned later from the explorer.
|
||||
try:
|
||||
item = enrich_place(item)
|
||||
except Exception as exc:
|
||||
item.update({"website_status": "unknown", "website_checked_at": now(), "website_error": "analysis_failed:" + str(exc)[:240], "email_evidence": item.get("email_evidence", "[]"), "score_reasons": "[]"})
|
||||
item["opportunity_score"] = score_opportunity(item)[0]
|
||||
if progress:
|
||||
progress(index, total)
|
||||
emails = set(normalize_public_emails(item.get("emails")))
|
||||
if item["domain"].lower() in suppressed_domains or emails.intersection(suppressed_emails):
|
||||
continue
|
||||
cur = conn.execute("""INSERT OR IGNORE INTO prospects(
|
||||
try:
|
||||
cur = conn.execute("""INSERT OR IGNORE INTO prospects(
|
||||
name,website,domain,description,query,discovered_at,source,source_id,
|
||||
category,address,phone,emails,rating,review_count,maps_url,latitude,
|
||||
longitude,listing_status,website_status,website_http_status,website_final_url,
|
||||
@@ -825,7 +833,11 @@ def insert_catalogue(run_id: int, query: str, raw_results: list[dict[str, Any]],
|
||||
item.get("website_tls_expires_at", ""), item.get("website_checked_at", ""), item.get("website_error", ""),
|
||||
item.get("email_evidence", "[]"), item.get("score_reasons", "[]"), None, "", "", "", "", "", "",
|
||||
item["opportunity_score"], item["raw_json"],
|
||||
))
|
||||
))
|
||||
except (sqlite3.Error, TypeError, ValueError):
|
||||
# Keep processing the remaining listings if one malformed
|
||||
# provider row cannot be written.
|
||||
continue
|
||||
if cur.rowcount:
|
||||
added += 1
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user