Compare commits
4 Commits
e3db8dbd93
...
9eae016283
| Author | SHA1 | Date | |
|---|---|---|---|
| 9eae016283 | |||
| 4e40d5e0ad | |||
| 48a4f3ae2e | |||
| 267e864afd |
@@ -1 +1 @@
|
||||
{"task_id": "2f988f42-8544-800e-abc1-d1b1c56ade4d", "token": "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", "readme_path": "readme.md", "session_start_time": "2026-02-24T14:02:27.897093"}
|
||||
{"task_id": "31188f42-8544-8074-bad3-d3e1b9b4051f", "token": "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", "readme_path": "connector-superoffice/README.md", "session_start_time": "2026-02-25T18:08:58.087419"}
|
||||
@@ -1,21 +0,0 @@
|
||||
import sqlite3
|
||||
|
||||
db_path = "/app/company-explorer/companies_v3_fixed_2.db"
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
tables = cursor.fetchall()
|
||||
print(f"Tables in {db_path}: {tables}")
|
||||
|
||||
# Check content of 'signals' if it exists
|
||||
if ('signals',) in tables:
|
||||
print("\nChecking 'signals' table for Wolfra (id=12)...")
|
||||
cursor.execute("SELECT * FROM signals WHERE account_id=12")
|
||||
columns = [desc[0] for desc in cursor.description]
|
||||
rows = cursor.fetchall()
|
||||
for row in rows:
|
||||
print(dict(zip(columns, row)))
|
||||
|
||||
conn.close()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Check for API Key
|
||||
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
|
||||
if not NOTION_API_KEY:
|
||||
try:
|
||||
with open("/app/n8n_api_Token_git.txt", "r") as f:
|
||||
content = f.read()
|
||||
if "secret_" in content:
|
||||
NOTION_API_KEY = content.strip().split('\n')[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
if not NOTION_API_KEY:
|
||||
print("Error: NOTION_API_KEY not found.")
|
||||
exit(1)
|
||||
|
||||
NOTION_DB_ID = "2ec88f4285448014ab38ea664b4c2b81"
|
||||
headers = {"Authorization": f"Bearer {NOTION_API_KEY}", "Notion-Version": "2022-06-28", "Content-Type": "application/json"}
|
||||
|
||||
def list_db_properties():
|
||||
url = f"https://api.notion.com/v1/databases/{NOTION_DB_ID}"
|
||||
resp = requests.get(url, headers=headers)
|
||||
if resp.status_code == 200:
|
||||
props = resp.json().get("properties", {})
|
||||
print("Database Properties:")
|
||||
for name, data in props.items():
|
||||
print(f"- {name} (Type: {data['type']})")
|
||||
else:
|
||||
print(f"Error getting DB: {resp.text}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
list_db_properties()
|
||||
@@ -0,0 +1,97 @@
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Check for API Key
|
||||
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
|
||||
if not NOTION_API_KEY:
|
||||
try:
|
||||
with open("/app/n8n_api_Token_git.txt", "r") as f:
|
||||
content = f.read()
|
||||
if "secret_" in content:
|
||||
NOTION_API_KEY = content.strip().split('\n')[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
if not NOTION_API_KEY:
|
||||
print("Error: NOTION_API_KEY not found.")
|
||||
exit(1)
|
||||
|
||||
NOTION_DB_ID = "2ec88f4285448014ab38ea664b4c2b81"
|
||||
headers = {"Authorization": f"Bearer {NOTION_API_KEY}", "Notion-Version": "2022-06-28", "Content-Type": "application/json"}
|
||||
|
||||
# Updates Definition
|
||||
updates = {
|
||||
"Energy - Grid & Utilities": {
|
||||
"Pains": "[Primary Product: Security]\n- Sabotage & Diebstahl: Kupferdiebstahl in Umspannwerken verursacht Millionenschäden und Versorgungsausfälle.\n- Reaktionszeit: Entlegene Standorte sind für Interventionskräfte oft zu spät erreichbar.\n- Sicherheitsrisiko Mensch: Alleinarbeit bei Kontrollgängen in Hochspannungsbereichen ist gefährlich.\n\n[Secondary Product: Cleaning Indoor]\n- Verschmutzung in Umspannwerken: Staubablagerungen auf Böden und in technischen Bereichen können die Betriebssicherheit gefährden.\n- Manuelle Reinigung in Sicherheitsbereichen: Externes Reinigungspersonal benötigt aufwändige Sicherheitsunterweisungen und Begleitung.\n- Große Distanzen: Die Reinigung weitläufiger, oft unbemannter Anlagen ist logistisch aufwändig und wird häufig vernachlässigt.",
|
||||
"Gains": "[Primary Product: Security]\n- First Responder Maschine: Roboter ist bereits vor Ort, verifiziert Alarm und schreckt Täter ab.\n- KRITIS-Compliance: Lückenlose, manipulationssichere Dokumentation aller Vorfälle für Behörden.\n- Arbeitsschutz: Roboter übernimmt gefährliche Routinekontrollen (z.B. Thermografie an Trafos).\n\n[Secondary Product: Cleaning Indoor]\n- Permanente Sauberkeit: Autonome Reinigung gewährleistet staubfreie Böden und reduziert das Risiko von technischen Störungen.\n- Zugang ohne Sicherheitsrisiko: Der Roboter ist \"Teil der Anlage\" und benötigt keine externe Sicherheitsfreigabe oder Begleitung.\n- Ressourceneffizienz: Kosteneffiziente Reinigung großer Flächen ohne Anreisezeiten für Dienstleister.",
|
||||
"Secondary_Product_Name": "Cleaning Indoor (Wet Surface)"
|
||||
},
|
||||
"Retail - Non-Food": {
|
||||
"Pains": "[Primary Product: Cleaning Indoor]\n- Optischer Eindruck: Verschmutzte Böden, insbesondere im Premium-Segment (Möbel, Elektronik), mindern die Wertwahrnehmung der ausgestellten Produkte massiv.\n- Staubentwicklung auf großen Flächen: In Möbelhäusern und Baumärkten sammelt sich auf den riesigen Gangflächen schnell Staub, der das Einkaufserlebnis trübt.\n- Personalbindung: Verkaufsberater sollen Kunden betreuen und Umsatz generieren, statt wertvolle Zeit mit unproduktiven Kehr- oder Wischtätigkeiten zu verbringen.\n\n[Secondary Product: Service]\n- Unübersichtlichkeit: Kunden finden in großen Märkten oft nicht sofort das gesuchte Produkt und binden Personal für einfache Wegbeschreibungen.\n- Fehlende Interaktion: Passive Verkaufsflächen bieten wenig Anreiz für Kunden, sich länger aufzuhalten oder zu interagieren.",
|
||||
"Gains": "[Primary Product: Cleaning Indoor]\n- Perfektes Einkaufserlebnis: Stets makellos saubere Böden unterstreichen den Qualitätsanspruch des Sortiments und laden zum Verweilen ein.\n- Fokus auf Beratung: Mitarbeiter werden von routinemäßigen Reinigungsaufgaben befreit und können sich voll auf den Kunden und den Verkauf konzentrieren.\n- Kosteneffizienz auf der Fläche: Autonome Reinigung großer Quadratmeterzahlen ist deutlich günstiger als manuelle Arbeit, besonders außerhalb der Öffnungszeiten.\n\n[Secondary Product: Service]\n- Innovativer Kundenservice: Roboter führen Kunden autonom zum gesuchten Produktregal (\"Guide-Funktion\").\n- Wow-Effekt: Der Einsatz von Robotik modernisiert das Markenimage und zieht Aufmerksamkeit auf sich."
|
||||
},
|
||||
"Tech - Data Center": {
|
||||
"Pains": "[Primary Product: Security]\n- Sicherheitsrisiko Zutritt: Unbefugter Zutritt in Hochsicherheitsbereiche (Serverräume, Cages) muss lückenlos detektiert und dokumentiert werden, um Zertifizierungen (ISO 27001) nicht zu gefährden.\n- Fachkräftemangel Security: Qualifiziertes Wachpersonal mit Sicherheitsüberprüfung ist extrem schwer zu finden und teuer im 24/7-Schichtbetrieb.\n- Dokumentationslücken: Manuelle Patrouillen sind fehleranfällig und Protokolle können unvollständig sein, was bei Audits zu Problemen führt.\n\n[Secondary Product: Cleaning Indoor]\n- Gefahr durch Staubpartikel: Feinstaub in Serverräumen kann Kühlsysteme verstopfen und Kurzschlüsse verursachen, was die Hardware-Lebensdauer verkürzt.\n- Sicherheitsrisiko Reinigungspersonal: Externes Reinigungspersonal in Sicherheitsbereichen erfordert ständige Begleitung und Überwachung (Vier-Augen-Prinzip), was Personal bindet.",
|
||||
"Gains": "[Primary Product: Security]\n- Lückenloser Audit-Trail: Automatisierte, manipulationssichere Dokumentation aller Kontrollgänge und Ereignisse sichert Compliance-Anforderungen.\n- 24/7 Präsenz: Der Roboter ist immer im Dienst, wird nicht müde und garantiert eine konstante Überwachungsqualität ohne Schichtwechsel-Risiken.\n- Sofortige Alarmierung: Bei Anomalien (offene Rack-Tür, Wärmeentwicklung) erfolgt eine Echtzeit-Meldung an die Leitzentrale.\n\n[Secondary Product: Cleaning Indoor]\n- Maximale Hardware-Verfügbarkeit: Staubfreie Umgebung optimiert die Kühleffizienz und reduziert das Ausfallrisiko teurer Komponenten.\n- Autonome \"Trusted\" Cleaning: Der Roboter reinigt sensibelste Bereiche ohne das Risiko menschlichen Fehlverhaltens oder unbefugten Zugriffs.",
|
||||
"Secondary_Product_Name": "Cleaning Indoor (Wet Surface)"
|
||||
}
|
||||
}
|
||||
|
||||
def get_product_page_id(product_name):
|
||||
url = "https://api.notion.com/v1/search"
|
||||
payload = {"query": product_name, "filter": {"value": "page", "property": "object"}}
|
||||
resp = requests.post(url, headers=headers, json=payload)
|
||||
if resp.status_code == 200:
|
||||
results = resp.json().get("results", [])
|
||||
if results: return results[0]["id"]
|
||||
return None
|
||||
|
||||
def update_vertical(vertical_name, new_data):
|
||||
url = f"https://api.notion.com/v1/databases/{NOTION_DB_ID}/query"
|
||||
payload = {"filter": {"property": "Vertical", "title": {"contains": vertical_name}}}
|
||||
resp = requests.post(url, headers=headers, json=payload)
|
||||
|
||||
if resp.status_code != 200:
|
||||
print(f"Error searching for {vertical_name}: {resp.text}")
|
||||
return
|
||||
|
||||
results = resp.json().get("results", [])
|
||||
if not results:
|
||||
print(f"Skipping {vertical_name} (Not found)")
|
||||
return
|
||||
|
||||
page_id = results[0]["id"]
|
||||
print(f"Found {vertical_name} (ID: {page_id})")
|
||||
|
||||
props_update = {
|
||||
"Pains": {"rich_text": [{"text": {"content": new_data["Pains"]}}],},
|
||||
"Gains": {"rich_text": [{"text": {"content": new_data["Gains"]}}]}
|
||||
}
|
||||
|
||||
if "Secondary_Product_Name" in new_data:
|
||||
prod_name = new_data["Secondary_Product_Name"]
|
||||
prod_id = get_product_page_id(prod_name)
|
||||
if prod_id:
|
||||
print(f" Found Product ID for '{prod_name}': {prod_id}")
|
||||
props_update["Secondary Product Category"] = {"relation": [{"id": prod_id}]}
|
||||
props_update["Ops Focus Secondary"] = {"checkbox": True}
|
||||
else:
|
||||
print(f" WARNING: Product '{prod_name}' not found.")
|
||||
|
||||
update_url = f"https://api.notion.com/v1/pages/{page_id}"
|
||||
update_payload = {"properties": props_update}
|
||||
resp_patch = requests.patch(update_url, headers=headers, json=update_payload)
|
||||
|
||||
if resp_patch.status_code == 200:
|
||||
print(f"✅ Successfully updated {vertical_name}")
|
||||
else:
|
||||
print(f"❌ Failed to update {vertical_name}: {resp_patch.text}")
|
||||
|
||||
print("Starting Targeted Notion Update...")
|
||||
for v_name, data in updates.items():
|
||||
update_vertical(v_name, data)
|
||||
print("Done.")
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Check for API Key
|
||||
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
|
||||
if not NOTION_API_KEY:
|
||||
try:
|
||||
with open("/app/n8n_api_Token_git.txt", "r") as f:
|
||||
content = f.read()
|
||||
if "secret_" in content:
|
||||
NOTION_API_KEY = content.strip().split('\n')[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
if not NOTION_API_KEY:
|
||||
print("Error: NOTION_API_KEY not found.")
|
||||
exit(1)
|
||||
|
||||
NOTION_DB_ID = "2ec88f4285448014ab38ea664b4c2b81"
|
||||
headers = {"Authorization": f"Bearer {NOTION_API_KEY}", "Notion-Version": "2022-06-28", "Content-Type": "application/json"}
|
||||
|
||||
targets = [
|
||||
"Energy - Grid & Utilities",
|
||||
"Tech - Data Center",
|
||||
"Retail - Non-Food"
|
||||
]
|
||||
|
||||
def check_vertical(vertical_name):
|
||||
print(f"\n--- Checking: {vertical_name} ---")
|
||||
url = f"https://api.notion.com/v1/databases/{NOTION_DB_ID}/query"
|
||||
payload = {"filter": {"property": "Vertical", "title": {"contains": vertical_name}}}
|
||||
resp = requests.post(url, headers=headers, json=payload)
|
||||
|
||||
if resp.status_code != 200:
|
||||
print(f"Error: {resp.text}")
|
||||
return
|
||||
|
||||
results = resp.json().get("results", [])
|
||||
if not results:
|
||||
print("Not found.")
|
||||
return
|
||||
|
||||
page = results[0]
|
||||
props = page["properties"]
|
||||
|
||||
# Check Pains (Start)
|
||||
pains = props.get("Pains", {}).get("rich_text", [])
|
||||
pains_text = "".join([t["text"]["content"] for t in pains])
|
||||
print(f"PAINS (First 100 chars): {pains_text[:100]}...")
|
||||
|
||||
# Check Gains (Start)
|
||||
gains = props.get("Gains", {}).get("rich_text", [])
|
||||
gains_text = "".join([t["text"]["content"] for t in gains])
|
||||
print(f"GAINS (First 100 chars): {gains_text[:100]}...")
|
||||
|
||||
# Check Ops Focus Secondary
|
||||
ops_focus = props.get("Ops Focus: Secondary", {}).get("checkbox", False)
|
||||
print(f"Ops Focus Secondary: {ops_focus}")
|
||||
|
||||
# Check Secondary Product
|
||||
sec_prod_rel = props.get("Secondary Product", {}).get("relation", [])
|
||||
if sec_prod_rel:
|
||||
prod_id = sec_prod_rel[0]["id"]
|
||||
# Fetch Product Name
|
||||
prod_url = f"https://api.notion.com/v1/pages/{prod_id}"
|
||||
prod_resp = requests.get(prod_url, headers=headers)
|
||||
if prod_resp.status_code == 200:
|
||||
prod_props = prod_resp.json()["properties"]
|
||||
# Try to find Name/Title
|
||||
# Usually "Name" or "Product Name"
|
||||
# Let's look for title type
|
||||
prod_name = "Unknown"
|
||||
for k, v in prod_props.items():
|
||||
if v["type"] == "title":
|
||||
prod_name = "".join([t["text"]["content"] for t in v["title"]])
|
||||
print(f"Secondary Product: {prod_name}")
|
||||
else:
|
||||
print(f"Secondary Product ID: {prod_id} (Could not fetch name)")
|
||||
else:
|
||||
print("Secondary Product: None")
|
||||
|
||||
for t in targets:
|
||||
check_vertical(t)
|
||||
@@ -196,9 +196,10 @@ Um die Zertifizierung für den SuperOffice App Store zu erhalten, mussten kritis
|
||||
* **Lösung:** Implementierung von **OData `$select`**. Wir fordern nun strikt nur die Felder an, die wir wirklich benötigen (z.B. `get_person(id, select=['JobTitle', 'UserDefinedFields'])`).
|
||||
* **Wichtig:** Niemals pauschal `get_person()` aufrufen, wenn nur die Rolle geprüft werden soll.
|
||||
|
||||
2. **NullReference bei `$select`:**
|
||||
* **Problem:** Wenn `$select` genutzt wird, gibt SuperOffice nicht angeforderte komplexe Objekte (wie `Contact` in `Person`) als `null` zurück. Der Zugriff `person['Contact']['ContactId']` führt dann zum Crash.
|
||||
* **Lösung:** Robuste Checks (`if contact_obj and isinstance(contact_obj, dict)`) und primäre Nutzung der IDs direkt aus dem Webhook-Payload (`FieldValues`), um API-Calls komplett zu vermeiden.
|
||||
3. **PUT vs. PATCH (Safe Updates):**
|
||||
* **Problem:** Die Verwendung von `PUT` zum Aktualisieren von Entitäten (Person/Contact) erfordert, dass das *gesamte* Objekt gesendet wird. Dies birgt das Risiko, Felder zu überschreiben, die zwischenzeitlich von anderen Benutzern geändert wurden ("Race Condition"), und verursacht unnötigen Traffic.
|
||||
* **Lösung:** Umstellung auf **`PATCH`**. Wir senden nun nur noch die *tatsächlich geänderten Felder* (Delta).
|
||||
* **Implementierung:** Der Worker baut nun ein `patch_payload` (z.B. `{'Position': {'Id': 123}}`) und nutzt den dedizierten PATCH-Endpunkt. Dies wurde explizit von SuperOffice für die Zertifizierung gefordert.
|
||||
|
||||
## Appendix: The "First Sentence" Prompt
|
||||
This is the core logic used to generate the company-specific opener.
|
||||
|
||||
@@ -80,6 +80,8 @@ class SuperOfficeClient:
|
||||
resp = requests.post(url, headers=self.headers, json=payload)
|
||||
elif method == "PUT":
|
||||
resp = requests.put(url, headers=self.headers, json=payload)
|
||||
elif method == "PATCH":
|
||||
resp = requests.patch(url, headers=self.headers, json=payload)
|
||||
|
||||
# 401 Handling
|
||||
if resp.status_code == 401 and retry:
|
||||
@@ -109,6 +111,9 @@ class SuperOfficeClient:
|
||||
def _put(self, endpoint, payload):
|
||||
return self._request_with_retry("PUT", endpoint, payload)
|
||||
|
||||
def _patch(self, endpoint, payload):
|
||||
return self._request_with_retry("PATCH", endpoint, payload)
|
||||
|
||||
def _post(self, endpoint, payload):
|
||||
return self._request_with_retry("POST", endpoint, payload)
|
||||
|
||||
@@ -196,53 +201,45 @@ class SuperOfficeClient:
|
||||
|
||||
def update_entity_udfs(self, entity_id: int, entity_type: str, udf_data: dict):
|
||||
"""
|
||||
Updates UDFs for a given entity (Contact or Person).
|
||||
Updates UDFs for a given entity (Contact or Person) using PATCH.
|
||||
entity_type: 'Contact' or 'Person'
|
||||
udf_data: {ProgId: Value}
|
||||
"""
|
||||
endpoint = f"{entity_type}/{entity_id}"
|
||||
|
||||
# 1. GET existing
|
||||
existing_entity = self._get(endpoint)
|
||||
if not existing_entity:
|
||||
logger.error(f"❌ Failed to retrieve existing {entity_type} {entity_id} for UDF update.")
|
||||
return False
|
||||
|
||||
if "UserDefinedFields" not in existing_entity:
|
||||
existing_entity["UserDefinedFields"] = {}
|
||||
# Construct PATCH payload
|
||||
payload = {
|
||||
"UserDefinedFields": udf_data
|
||||
}
|
||||
|
||||
# 2. Merge payload
|
||||
existing_entity["UserDefinedFields"].update(udf_data)
|
||||
logger.info(f"Patching {entity_type} {entity_id} UDFs: {udf_data}...")
|
||||
|
||||
logger.info(f"Updating {entity_type} {entity_id} UDFs: {udf_data}...")
|
||||
|
||||
# 3. PUT update
|
||||
result = self._put(endpoint, existing_entity)
|
||||
# PATCH update
|
||||
result = self._patch(endpoint, payload)
|
||||
return bool(result)
|
||||
|
||||
def update_person_position(self, person_id: int, position_id: int):
|
||||
"""
|
||||
Updates the standard 'Position' field of a Person.
|
||||
Updates the standard 'Position' field of a Person using PATCH.
|
||||
"""
|
||||
endpoint = f"Person/{person_id}"
|
||||
|
||||
# 1. GET existing
|
||||
existing_person = self._get(endpoint)
|
||||
if not existing_person:
|
||||
logger.error(f"❌ Failed to retrieve Person {person_id} for Position update.")
|
||||
return False
|
||||
|
||||
# 2. Check current value to avoid redundant updates
|
||||
current_pos = existing_person.get("Position", {})
|
||||
if current_pos and str(current_pos.get("Id")) == str(position_id):
|
||||
logger.info(f"Person {person_id} Position already set to {position_id}. Skipping.")
|
||||
return True
|
||||
# Construct PATCH payload
|
||||
payload = {
|
||||
"Position": {"Id": int(position_id)}
|
||||
}
|
||||
|
||||
logger.info(f"Patching Person {person_id} Position to ID {position_id}...")
|
||||
|
||||
# PATCH update
|
||||
result = self._patch(endpoint, payload)
|
||||
return bool(result)
|
||||
|
||||
# 3. Update
|
||||
existing_person["Position"] = {"Id": int(position_id)}
|
||||
|
||||
logger.info(f"Updating Person {person_id} Position to ID {position_id}...")
|
||||
|
||||
# 4. PUT
|
||||
result = self._put(endpoint, existing_person)
|
||||
def patch_contact(self, contact_id: int, patch_data: dict):
|
||||
"""
|
||||
Generic PATCH for Contact entity.
|
||||
"""
|
||||
endpoint = f"Contact/{contact_id}"
|
||||
logger.info(f"Patching Contact {contact_id} with data keys: {list(patch_data.keys())}...")
|
||||
result = self._patch(endpoint, patch_data)
|
||||
return bool(result)
|
||||
@@ -214,8 +214,7 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
logger.error(f"Failed to fetch contact {contact_id}: {e}")
|
||||
return "RETRY"
|
||||
|
||||
dirty_standard = False
|
||||
dirty_udfs = False
|
||||
contact_patch = {}
|
||||
|
||||
if "UserDefinedFields" not in contact_data: contact_data["UserDefinedFields"] = {}
|
||||
|
||||
@@ -233,8 +232,7 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
|
||||
if str(current_val) != str(vertical_id):
|
||||
logger.info(f"Change detected: Vertical {current_val} -> {vertical_id}")
|
||||
contact_data["UserDefinedFields"][udf_key] = str(vertical_id)
|
||||
dirty_udfs = True
|
||||
contact_patch.setdefault("UserDefinedFields", {})[udf_key] = str(vertical_id)
|
||||
except Exception as e:
|
||||
logger.error(f"Vertical sync error: {e}")
|
||||
|
||||
@@ -252,26 +250,23 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
if "Postal" not in addr_obj or addr_obj["Postal"] is None: addr_obj["Postal"] = {}
|
||||
if "Street" not in addr_obj or addr_obj["Street"] is None: addr_obj["Street"] = {}
|
||||
|
||||
def update_addr_field(field_name, new_val, log_name):
|
||||
nonlocal dirty_standard
|
||||
def update_addr_patch(field_name, new_val, log_name):
|
||||
if new_val:
|
||||
for type_key in ["Postal", "Street"]:
|
||||
cur = addr_obj[type_key].get(field_name, "")
|
||||
if cur != new_val:
|
||||
logger.info(f"Change detected: {type_key} {log_name} '{cur}' -> '{new_val}'")
|
||||
addr_obj[type_key][field_name] = new_val
|
||||
dirty_standard = True
|
||||
contact_patch.setdefault("Address", {}).setdefault(type_key, {})[field_name] = new_val
|
||||
|
||||
update_addr_field("City", ce_city, "City")
|
||||
update_addr_field("Address1", ce_street, "Street")
|
||||
update_addr_field("Zipcode", ce_zip, "Zip")
|
||||
update_addr_patch("City", ce_city, "City")
|
||||
update_addr_patch("Address1", ce_street, "Street")
|
||||
update_addr_patch("Zipcode", ce_zip, "Zip")
|
||||
|
||||
if ce_vat:
|
||||
current_vat = contact_data.get("OrgNr", "")
|
||||
if current_vat != ce_vat:
|
||||
logger.info(f"Change detected: VAT '{current_vat}' -> '{ce_vat}'")
|
||||
contact_data["OrgNr"] = ce_vat
|
||||
dirty_standard = True
|
||||
contact_patch["OrgNr"] = ce_vat
|
||||
|
||||
# --- C. AI Openers Sync ---
|
||||
ce_opener = provisioning_data.get("opener")
|
||||
@@ -281,25 +276,25 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
current_opener = contact_data["UserDefinedFields"].get(settings.UDF_OPENER, "")
|
||||
if current_opener != ce_opener:
|
||||
logger.info("Change detected: Primary Opener")
|
||||
contact_data["UserDefinedFields"][settings.UDF_OPENER] = ce_opener
|
||||
dirty_udfs = True
|
||||
contact_patch.setdefault("UserDefinedFields", {})[settings.UDF_OPENER] = ce_opener
|
||||
|
||||
if ce_opener_secondary and ce_opener_secondary != "null":
|
||||
current_opener_sec = contact_data["UserDefinedFields"].get(settings.UDF_OPENER_SECONDARY, "")
|
||||
if current_opener_sec != ce_opener_secondary:
|
||||
logger.info("Change detected: Secondary Opener")
|
||||
contact_data["UserDefinedFields"][settings.UDF_OPENER_SECONDARY] = ce_opener_secondary
|
||||
dirty_udfs = True
|
||||
contact_patch.setdefault("UserDefinedFields", {})[settings.UDF_OPENER_SECONDARY] = ce_opener_secondary
|
||||
|
||||
# --- D. Apply Updates (Single Transaction) ---
|
||||
if dirty_standard or dirty_udfs:
|
||||
logger.info(f"Pushing combined updates for Contact {contact_id}...")
|
||||
# --- D. Apply Updates (Single PATCH Transaction) ---
|
||||
if contact_patch:
|
||||
logger.info(f"Pushing combined PATCH updates for Contact {contact_id}...")
|
||||
try:
|
||||
so_client._put(f"Contact/{contact_id}", contact_data)
|
||||
logger.info("✅ Contact Update Successful.")
|
||||
so_client.patch_contact(contact_id, contact_patch)
|
||||
logger.info("✅ Contact Update Successful (PATCH).")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to update Contact {contact_id}: {e}")
|
||||
raise
|
||||
else:
|
||||
logger.info(f"No changes detected for Contact {contact_id}. Skipping update.")
|
||||
|
||||
# 2d. Sync Person Position (Role) - if Person exists
|
||||
role_name = provisioning_data.get("role_name")
|
||||
|
||||
15
devtools/db_utils/inspect_schema.py
Normal file
15
devtools/db_utils/inspect_schema.py
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import sqlite3
|
||||
|
||||
def list_industries_schema():
|
||||
conn = sqlite3.connect('/app/companies_v3_fixed_2.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("PRAGMA table_info(industries)")
|
||||
columns = cursor.fetchall()
|
||||
print("Columns in 'industries' table:")
|
||||
for col in columns:
|
||||
print(f"Name: {col[1]}, Type: {col[2]}")
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
list_industries_schema()
|
||||
15
devtools/db_utils/list_robotics_categories.py
Normal file
15
devtools/db_utils/list_robotics_categories.py
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import sqlite3
|
||||
|
||||
def list_categories():
|
||||
conn = sqlite3.connect('/app/companies_v3_fixed_2.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT id, name FROM robotics_categories")
|
||||
rows = cursor.fetchall()
|
||||
print("Categories:")
|
||||
for r in rows:
|
||||
print(f"ID: {r[0]}, Name: {r[1]}")
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
list_categories()
|
||||
14
devtools/db_utils/list_tables.py
Normal file
14
devtools/db_utils/list_tables.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import sqlite3
|
||||
|
||||
def list_tables():
|
||||
conn = sqlite3.connect('/app/companies_v3_fixed_2.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
tables = cursor.fetchall()
|
||||
print("Tables in database:")
|
||||
for table in tables:
|
||||
print(table[0])
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
list_tables()
|
||||
29
devtools/db_utils/read_vertical_data.py
Normal file
29
devtools/db_utils/read_vertical_data.py
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
import sqlite3
|
||||
|
||||
def read_verticals():
|
||||
conn = sqlite3.connect('/app/companies_v3_fixed_2.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
verticals = [
|
||||
"Energy - Grid & Utilities",
|
||||
"Retail - Non-Food",
|
||||
"Tech - Data Center",
|
||||
"Healthcare - Hospital"
|
||||
]
|
||||
|
||||
for v_name in verticals:
|
||||
cursor.execute("SELECT name, pains, gains, primary_category_id, secondary_category_id, ops_focus_secondary FROM industries WHERE name = ?", (v_name,))
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
print(f"--- {row[0]} ---")
|
||||
print(f"Primary ID: {row[3]}, Secondary ID: {row[4]}, Ops Focus Secondary: {row[5]}")
|
||||
print(f"PAINS:\n{row[1]}")
|
||||
print(f"GAINS:\n{row[2]}\n")
|
||||
else:
|
||||
print(f"Vertical '{v_name}' not found.")
|
||||
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
read_verticals()
|
||||
20
devtools/history/fix_tech_id_2026-02-24.py
Normal file
20
devtools/history/fix_tech_id_2026-02-24.py
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
import sqlite3
|
||||
|
||||
def fix_tech_id():
|
||||
db_path = '/app/companies_v3_fixed_2.db'
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE industries
|
||||
SET secondary_category_id = 9
|
||||
WHERE name = 'Tech - Data Center'
|
||||
""")
|
||||
print("Updated Tech - Data Center Secondary ID to 9")
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
fix_tech_id()
|
||||
100
devtools/history/update_verticals_2026-02-24.py
Normal file
100
devtools/history/update_verticals_2026-02-24.py
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
import sqlite3
|
||||
|
||||
def update_verticals():
|
||||
db_path = '/app/companies_v3_fixed_2.db'
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 1. Energy - Grid & Utilities
|
||||
# Update Secondary Product to 9 (Cleaning Indoor Wet) and update Texts
|
||||
energy_pains = """[Primary Product: Security]
|
||||
- Sabotage & Diebstahl: Kupferdiebstahl in Umspannwerken verursacht Millionenschäden und Versorgungsausfälle.
|
||||
- Reaktionszeit: Entlegene Standorte sind für Interventionskräfte oft zu spät erreichbar.
|
||||
- Sicherheitsrisiko Mensch: Alleinarbeit bei Kontrollgängen in Hochspannungsbereichen ist gefährlich.
|
||||
|
||||
[Secondary Product: Cleaning Indoor]
|
||||
- Verschmutzung in Umspannwerken: Staubablagerungen auf Böden und in technischen Bereichen können die Betriebssicherheit gefährden.
|
||||
- Manuelle Reinigung in Sicherheitsbereichen: Externes Reinigungspersonal benötigt aufwändige Sicherheitsunterweisungen und Begleitung.
|
||||
- Große Distanzen: Die Reinigung weitläufiger, oft unbemannter Anlagen ist logistisch aufwändig und wird häufig vernachlässigt."""
|
||||
|
||||
energy_gains = """[Primary Product: Security]
|
||||
- First Responder Maschine: Roboter ist bereits vor Ort, verifiziert Alarm und schreckt Täter ab.
|
||||
- KRITIS-Compliance: Lückenlose, manipulationssichere Dokumentation aller Vorfälle für Behörden.
|
||||
- Arbeitsschutz: Roboter übernimmt gefährliche Routinekontrollen (z.B. Thermografie an Trafos).
|
||||
|
||||
[Secondary Product: Cleaning Indoor]
|
||||
- Permanente Sauberkeit: Autonome Reinigung gewährleistet staubfreie Böden und reduziert das Risiko von technischen Störungen.
|
||||
- Zugang ohne Sicherheitsrisiko: Der Roboter ist "Teil der Anlage" und benötigt keine externe Sicherheitsfreigabe oder Begleitung.
|
||||
- Ressourceneffizienz: Kosteneffiziente Reinigung großer Flächen ohne Anreisezeiten für Dienstleister."""
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE industries
|
||||
SET secondary_category_id = 9,
|
||||
pains = ?,
|
||||
gains = ?
|
||||
WHERE name = 'Energy - Grid & Utilities'
|
||||
""", (energy_pains, energy_gains))
|
||||
print("Updated Energy - Grid & Utilities")
|
||||
|
||||
# 2. Retail - Non-Food
|
||||
# Update Texts (Enrichment)
|
||||
retail_pains = """[Primary Product: Cleaning Indoor]
|
||||
- Optischer Eindruck: Verschmutzte Böden, insbesondere im Premium-Segment (Möbel, Elektronik), mindern die Wertwahrnehmung der ausgestellten Produkte massiv.
|
||||
- Staubentwicklung auf großen Flächen: In Möbelhäusern und Baumärkten sammelt sich auf den riesigen Gangflächen schnell Staub, der das Einkaufserlebnis trübt.
|
||||
- Personalbindung: Verkaufsberater sollen Kunden betreuen und Umsatz generieren, statt wertvolle Zeit mit unproduktiven Kehr- oder Wischtätigkeiten zu verbringen.
|
||||
|
||||
[Secondary Product: Service]
|
||||
- Unübersichtlichkeit: Kunden finden in großen Märkten oft nicht sofort das gesuchte Produkt und binden Personal für einfache Wegbeschreibungen.
|
||||
- Fehlende Interaktion: Passive Verkaufsflächen bieten wenig Anreiz für Kunden, sich länger aufzuhalten oder zu interagieren."""
|
||||
|
||||
retail_gains = """[Primary Product: Cleaning Indoor]
|
||||
- Perfektes Einkaufserlebnis: Stets makellos saubere Böden unterstreichen den Qualitätsanspruch des Sortiments und laden zum Verweilen ein.
|
||||
- Fokus auf Beratung: Mitarbeiter werden von routinemäßigen Reinigungsaufgaben befreit und können sich voll auf den Kunden und den Verkauf konzentrieren.
|
||||
- Kosteneffizienz auf der Fläche: Autonome Reinigung großer Quadratmeterzahlen ist deutlich günstiger als manuelle Arbeit, besonders außerhalb der Öffnungszeiten.
|
||||
|
||||
[Secondary Product: Service]
|
||||
- Innovativer Kundenservice: Roboter führen Kunden autonom zum gesuchten Produktregal ("Guide-Funktion").
|
||||
- Wow-Effekt: Der Einsatz von Robotik modernisiert das Markenimage und zieht Aufmerksamkeit auf sich."""
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE industries
|
||||
SET pains = ?,
|
||||
gains = ?
|
||||
WHERE name = 'Retail - Non-Food'
|
||||
""", (retail_pains, retail_gains))
|
||||
print("Updated Retail - Non-Food")
|
||||
|
||||
# 3. Tech - Data Center
|
||||
# Update Texts (Enrichment)
|
||||
tech_pains = """[Primary Product: Security]
|
||||
- Sicherheitsrisiko Zutritt: Unbefugter Zutritt in Hochsicherheitsbereiche (Serverräume, Cages) muss lückenlos detektiert und dokumentiert werden, um Zertifizierungen (ISO 27001) nicht zu gefährden.
|
||||
- Fachkräftemangel Security: Qualifiziertes Wachpersonal mit Sicherheitsüberprüfung ist extrem schwer zu finden und teuer im 24/7-Schichtbetrieb.
|
||||
- Dokumentationslücken: Manuelle Patrouillen sind fehleranfällig und Protokolle können unvollständig sein, was bei Audits zu Problemen führt.
|
||||
|
||||
[Secondary Product: Cleaning Indoor]
|
||||
- Gefahr durch Staubpartikel: Feinstaub in Serverräumen kann Kühlsysteme verstopfen und Kurzschlüsse verursachen, was die Hardware-Lebensdauer verkürzt.
|
||||
- Sicherheitsrisiko Reinigungspersonal: Externes Reinigungspersonal in Sicherheitsbereichen erfordert ständige Begleitung und Überwachung (Vier-Augen-Prinzip), was Personal bindet."""
|
||||
|
||||
tech_gains = """[Primary Product: Security]
|
||||
- Lückenloser Audit-Trail: Automatisierte, manipulationssichere Dokumentation aller Kontrollgänge und Ereignisse sichert Compliance-Anforderungen.
|
||||
- 24/7 Präsenz: Der Roboter ist immer im Dienst, wird nicht müde und garantiert eine konstante Überwachungsqualität ohne Schichtwechsel-Risiken.
|
||||
- Sofortige Alarmierung: Bei Anomalien (offene Rack-Tür, Wärmeentwicklung) erfolgt eine Echtzeit-Meldung an die Leitzentrale.
|
||||
|
||||
[Secondary Product: Cleaning Indoor]
|
||||
- Maximale Hardware-Verfügbarkeit: Staubfreie Umgebung optimiert die Kühleffizienz und reduziert das Ausfallrisiko teurer Komponenten.
|
||||
- Autonome "Trusted" Cleaning: Der Roboter reinigt sensibelste Bereiche ohne das Risiko menschlichen Fehlverhaltens oder unbefugten Zugriffs."""
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE industries
|
||||
SET pains = ?,
|
||||
gains = ?
|
||||
WHERE name = 'Tech - Data Center'
|
||||
""", (tech_pains, tech_gains))
|
||||
print("Updated Tech - Data Center")
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_verticals()
|
||||
@@ -1,24 +0,0 @@
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
db_path = "/home/node/clawd/repos/brancheneinstufung2/company-explorer/backend/companies_v3_fixed_2.db"
|
||||
|
||||
if not os.path.exists(db_path):
|
||||
# Fallback to check other potential locations
|
||||
db_path = "/home/node/clawd/repos/brancheneinstufung2/companies_v3_fixed_2.db"
|
||||
|
||||
print(f"--- Inspecting Database: {db_path} ---")
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("PRAGMA table_info(companies)")
|
||||
columns = cursor.fetchall()
|
||||
|
||||
print("Columns in table 'companies':")
|
||||
for col in columns:
|
||||
print(f"- {col[1]} ({col[2]})")
|
||||
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
BIN
uploads_audio/chunks/8/chunk_000.mp3
Normal file
BIN
uploads_audio/chunks/8/chunk_000.mp3
Normal file
Binary file not shown.
BIN
uploads_audio/d98838f4-1a77-447f-9842-af680b1cbc71.m4a
Normal file
BIN
uploads_audio/d98838f4-1a77-447f-9842-af680b1cbc71.m4a
Normal file
Binary file not shown.
Reference in New Issue
Block a user