fix(crm)!: remove unused get_last_interaction endpoint (backport #58214) (#58215)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2026-08-16 14:21:44 +00:00
committed by GitHub
parent 2aa1bf54f2
commit 0c625ff69b

View File

@@ -1,53 +1,6 @@
import frappe
@frappe.whitelist()
def get_last_interaction(contact=None, lead=None):
if not contact and not lead:
return
last_communication = None
last_issue = None
if contact:
query_condition = ""
values = []
contact = frappe.get_doc("Contact", contact)
for link in contact.links:
if link.link_doctype == "Customer":
last_issue = get_last_issue_from_customer(link.link_name)
query_condition += "(`reference_doctype`=%s AND `reference_name`=%s) OR"
values += [link.link_doctype, link.link_name]
if query_condition:
# remove extra appended 'OR'
query_condition = query_condition[:-2]
last_communication = frappe.db.sql(
f"""
SELECT `name`, `content`
FROM `tabCommunication`
WHERE `sent_or_received`='Received'
AND ({query_condition})
ORDER BY `modified`
LIMIT 1
""",
values,
as_dict=1,
) # nosec
if lead:
last_communication = frappe.get_all(
"Communication",
filters={"reference_doctype": "Lead", "reference_name": lead, "sent_or_received": "Received"},
fields=["name", "content"],
order_by="`creation` DESC",
limit=1,
)
last_communication = last_communication[0] if last_communication else None
return {"last_communication": last_communication, "last_issue": last_issue}
def get_last_issue_from_customer(customer_name):
issues = frappe.get_all(
"Issue",