[2ff88f42] einfügen

einfügen
This commit is contained in:
2026-02-24 07:13:49 +00:00
parent e39c745a78
commit bfb96118b0
15 changed files with 255 additions and 10 deletions

View File

@@ -16,13 +16,14 @@ logger = logging.getLogger(__name__)
NOTION_TOKEN_FILE = "/app/notion_token.txt"
# Sector & Persona Master DB
PERSONAS_DB_ID = "2e288f42-8544-8113-b878-ec99c8a02a6b"
PERSONAS_DB_ID = "30588f42-8544-80c3-8919-e22d74d945ea"
VALID_ARCHETYPES = {
"Wirtschaftlicher Entscheider",
"Operativer Entscheider",
"Infrastruktur-Verantwortlicher",
"Innovations-Treiber"
"Innovations-Treiber",
"Influencer"
}
def load_notion_token():
@@ -65,6 +66,10 @@ def extract_title(prop):
if not prop: return ""
return "".join([t.get("plain_text", "") for t in prop.get("title", [])])
def extract_rich_text(prop):
if not prop: return ""
return "".join([t.get("plain_text", "") for t in prop.get("rich_text", [])])
def extract_rich_text_to_list(prop):
"""
Extracts rich text and converts bullet points/newlines into a list of strings.
@@ -94,7 +99,8 @@ def sync_personas(token, session):
for page in pages:
props = page.get("properties", {})
name = extract_title(props.get("Name"))
# The title property is 'Role' in the new DB, not 'Name'
name = extract_title(props.get("Role"))
if name not in VALID_ARCHETYPES:
logger.debug(f"Skipping '{name}' (Not a target Archetype)")
@@ -105,6 +111,11 @@ def sync_personas(token, session):
pains_list = extract_rich_text_to_list(props.get("Pains"))
gains_list = extract_rich_text_to_list(props.get("Gains"))
description = extract_rich_text(props.get("Rollenbeschreibung"))
convincing_arguments = extract_rich_text(props.get("Was ihn überzeugt"))
typical_positions = extract_rich_text(props.get("Typische Positionen"))
kpis = extract_rich_text(props.get("KPIs"))
# Upsert Logic
persona = session.query(Persona).filter(Persona.name == name).first()
if not persona:
@@ -116,6 +127,10 @@ def sync_personas(token, session):
persona.pains = json.dumps(pains_list, ensure_ascii=False)
persona.gains = json.dumps(gains_list, ensure_ascii=False)
persona.description = description
persona.convincing_arguments = convincing_arguments
persona.typical_positions = typical_positions
persona.kpis = kpis
count += 1