bmc_hub/app/core/contact_utils.py
Christian 489f81a1e3 feat: Enhance hardware detail view with ESET data synchronization and specifications
- Added a button to sync ESET data in the hardware detail view.
- Introduced a new tab for ESET specifications, displaying relevant device information.
- Included ESET UUID and group details in the hardware information section.
- Implemented a JavaScript function to handle ESET data synchronization via API.
- Updated the ESET import template to improve device listing and inline contact selection.
- Enhanced the Nextcloud and locations routers to support customer ID resolution from contacts.
- Added utility functions for retrieving customer IDs linked to contacts.
- Removed debug information from the service contract wizard for cleaner output.
2026-02-11 23:51:21 +01:00

33 lines
820 B
Python

"""
Contact helpers for resolving linked customers.
"""
from typing import List, Optional
from app.core.database import execute_query
def get_contact_customer_ids(contact_id: int) -> List[int]:
query = """
SELECT customer_id
FROM contact_companies
WHERE contact_id = %s
ORDER BY is_primary DESC, customer_id
"""
rows = execute_query(query, (contact_id,)) or []
return [row["customer_id"] for row in rows]
def get_primary_customer_id(contact_id: int) -> Optional[int]:
query = """
SELECT customer_id
FROM contact_companies
WHERE contact_id = %s
ORDER BY is_primary DESC, customer_id
LIMIT 1
"""
rows = execute_query(query, (contact_id,)) or []
if not rows:
return None
return rows[0]["customer_id"]