mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Contact carries the best-priority mobile and landline Abri lists 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1d3219ca60
commit
1752a6cf10
1 changed files with 11 additions and 5 deletions
|
|
@ -30,12 +30,18 @@ def _format_appointment_date(appointment_date: date) -> str:
|
|||
return appointment_date.strftime("%d/%m/%Y")
|
||||
|
||||
|
||||
def _phone_priority(entry: ET.Element) -> Tuple[int, int]:
|
||||
"""Sort key: lowest numeric priority first; unusable priorities last."""
|
||||
try:
|
||||
return (0, int((entry.get("priority") or "").strip()))
|
||||
except ValueError:
|
||||
return (1, 0)
|
||||
|
||||
|
||||
def _select_phone_number(entries: List[ET.Element]) -> Optional[str]:
|
||||
for entry in entries:
|
||||
number = (entry.text or "").strip()
|
||||
if number:
|
||||
return number
|
||||
return None
|
||||
usable = [entry for entry in entries if (entry.text or "").strip()]
|
||||
ranked = sorted(usable, key=_phone_priority) # stable: ties keep document order
|
||||
return (ranked[0].text or "").strip() if ranked else None
|
||||
|
||||
|
||||
class AbriClient:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue