From c46822ddf8a60a820651df9122c95f470e508a88 Mon Sep 17 00:00:00 2001 From: Floke Date: Wed, 4 Mar 2026 17:51:55 +0000 Subject: [PATCH] =?UTF-8?q?[31188f42]=20Feat:=20Filterlogik=20f=C3=BCr=20'?= =?UTF-8?q?person.changed'=20Webhooks=20implementiert.=20Nur=20relevante?= =?UTF-8?q?=20=C3=84nderungen=20(Jobtitel,=20Position,=20UDFs)=20l=C3=B6se?= =?UTF-8?q?n=20eine=20KI-Verarbeitung=20aus.=20Irrelevante=20=C3=84nderung?= =?UTF-8?q?en=20(Telefon,=20etc.)=20werden=20ignoriert,=20um=20Loops=20und?= =?UTF-8?q?=20unn=C3=B6tige=20Last=20zu=20vermeiden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- connector-superoffice/worker.py | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/connector-superoffice/worker.py b/connector-superoffice/worker.py index 6e9f7b79..c788afc9 100644 --- a/connector-superoffice/worker.py +++ b/connector-superoffice/worker.py @@ -52,6 +52,47 @@ def process_job(job, so_client: SuperOfficeClient): except (ValueError, TypeError): pass + # 0b. Noise Reduction: Filter irrelevant field changes + # Only re-process if core data (Name, Website) or UDFs (Vertical) changed. + if job['event_type'] == 'contact.changed': + changes = payload.get('Changes', []) + # Normalize to lower case for comparison + changes_lower = [str(c).lower() for c in changes] + + # Fields that trigger a re-analysis + relevant_fields = [ + 'name', # Company Name change -> Full Re-Scan + 'urladdress', # Website change -> Full Re-Scan + 'urls', # Website array change + 'orgnr', # VAT/Register ID change + 'userdef_id', # UDFs (Verticals, etc.) changed + 'country_id' # Country change + ] + + # Check if ANY relevant field is in the changes list + is_relevant = any(field in changes_lower for field in relevant_fields) + + if not is_relevant: + logger.info(f"⏭️ Skipping 'contact.changed': No relevant fields changed. (Changes: {changes})") + return "SUCCESS" + + if job['event_type'] == 'person.changed': + changes = payload.get('Changes', []) + changes_lower = [str(c).lower() for c in changes] + + relevant_person_fields = [ + 'jobtitle', # Job Title change + 'title', # Alternative title field + 'position_id', # Standard Position/Role dropdown + 'userdef_id' # UDFs (MA Status, Campaign, etc.) + ] + + is_relevant = any(field in changes_lower for field in relevant_person_fields) + + if not is_relevant: + logger.info(f"⏭️ Skipping 'person.changed': No relevant fields changed. (Changes: {changes})") + return "SUCCESS" + # 1. Extract IDs Early person_id = None contact_id = None