feat: Oracle CRM Page, Synthetic Client Data and Live Snapshot when hitting emotion hotpoint

This commit is contained in:
Sagnik
2026-04-19 00:43:01 +05:30
parent f616a33ab0
commit 4b21c2cad6
197 changed files with 105054 additions and 89 deletions

View File

@@ -300,12 +300,15 @@ async def get_contact_list(
p.primary_email,
p.primary_phone,
p.buyer_type,
p.legacy_li_id,
p.created_at,
cl.lead_id,
cl.status AS lead_status,
cl.budget_band,
cl.urgency,
pi.project_name AS primary_interest,
COALESCE(qs.intent_value, 0.0) AS intent_score,
COALESCE(qs.engagement_value, qs.intent_value, 0.0) AS engagement_score,
COALESCE(qs.urgency_value, 0.0) AS urgency_score,
(SELECT COUNT(*) FROM intel_interactions ii WHERE ii.person_id = p.person_id) AS interaction_count,
(SELECT MAX(happened_at) FROM intel_interactions ii WHERE ii.person_id = p.person_id) AS last_interaction_at,
@@ -318,9 +321,17 @@ async def get_contact_list(
ORDER BY created_at DESC
LIMIT 1
) cl ON TRUE
LEFT JOIN LATERAL (
SELECT project_name
FROM crm_property_interests
WHERE person_id = p.person_id
ORDER BY priority ASC, created_at DESC
LIMIT 1
) pi ON TRUE
LEFT JOIN LATERAL (
SELECT
MAX(CASE WHEN score_type = 'intent_score' THEN current_value END) AS intent_value,
MAX(CASE WHEN score_type = 'engagement_score' THEN current_value END) AS engagement_value,
MAX(CASE WHEN score_type = 'urgency_score' THEN current_value END) AS urgency_value
FROM intel_qd_scores
WHERE person_id = p.person_id
@@ -350,10 +361,13 @@ async def get_contact_list(
"primary_phone": r["primary_phone"],
"buyer_type": r["buyer_type"],
"lead_id": str(r["lead_id"]) if r["lead_id"] else None,
"legacy_li_id": str(r["legacy_li_id"]) if r["legacy_li_id"] else None,
"lead_status": r["lead_status"],
"budget_band": r["budget_band"],
"urgency": r["urgency"],
"primary_interest": r["primary_interest"],
"intent_score": float(r["intent_score"]),
"engagement_score": float(r["engagement_score"]),
"urgency_score": float(r["urgency_score"]),
"interaction_count": int(r["interaction_count"]),
"last_interaction_at": r["last_interaction_at"].isoformat() if r["last_interaction_at"] else None,