fix(crm): guard first_contact result before indexing (lead conversion time)

Address review (#56105): the IS NOT NULL guard can return no rows (the count above
filters on sender, this query on recipients), so [0][0] would raise IndexError.
Fall back to None when empty, matching the prior behaviour for that case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-18 20:50:31 +05:30
parent cfa6d286ad
commit 5787951ed1

View File

@@ -130,7 +130,8 @@ def get_communication_details(filters):
LIMIT 1
""",
(d.contact_email),
)[0][0]
)
first_contact = first_contact[0][0] if first_contact else None
duration = flt(date_diff(invoice[0][0], first_contact))