New and improved with central fullfillment-pipeline and check for customer name and email adress

This commit is contained in:
peignerpausz committed 2026-11-13 16:34:31 +01:00
1 parent 6580517e9d
commit 47531ea971
11 files changed
+1331 -36

No files matched your search

@@ -0,0 +1,457 @@
#!/usr/bin/env python3
# fullfillment_updater.py
# zentrales Skript für die Aktualisierung der Fulfillment-Tickets in Jira
# Maintainer: peignerpausz
# Version: 1.0.0
import re
import csv
import base64
import requests
from datetime import datetime
# ==================================================
# KONFIGURATION
# ==================================================
JIRA_BASE_URL = "https://group-one.atlassian.net"
USER_EMAIL = "patrick.eigner-pausz@easyname.at"
API_TOKEN = "ATATT3xFfGF0iyWQgMQK0nzyAAv0CzsNW0A3edG3Tn24d4xR9rWUPa-tjwN58KGPkfbLpYEZThwVYY6KJVWQNwSqi6XPyktF0rcz9J_qkRLMwdADiB29ngg1UsCle-gkA0jQGHSyEBg7h52Rh_L5TcbvzSv6z6E-BO_WFYRrkBQPUg-RJLkZcO8=7AB0E5BE"
JQL_QUERY = (
'project = FUL AND '
'(textfields ~ "easyname-Bestellung*" OR textfields ~ "easyname Bestellung*") AND '
'statusCategory != Done '
'ORDER BY created ASC'
)
INPUT_CSV = "activation_overview.csv"
OUTPUT_MD = "activation_checklist.md"
# ==================================================
# AUTH
# ==================================================
auth_string = f"{USER_EMAIL}:{API_TOKEN}"
encoded_auth = base64.b64encode(
auth_string.encode("utf-8")
).decode("utf-8")
HEADERS = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": f"Basic {encoded_auth}"
}
# ==================================================
# ADF -> TEXT
# ==================================================
def adf_to_text(node):
if node is None:
return ""
if isinstance(node, str):
return node
if isinstance(node, list):
return " ".join(
adf_to_text(item)
for item in node
)
if isinstance(node, dict):
parts = []
if "text" in node:
parts.append(node["text"])
if "content" in node:
parts.append(
adf_to_text(node["content"])
)
return " ".join(parts)
return ""
# ==================================================
# KUNDE AUS JIRA ERMITTELN
# ==================================================
def extract_customer_number(text):
match = re.search(
r"Kunde:\s*(\d+)",
text,
re.IGNORECASE
)
if match:
return match.group(1)
return None
# ==================================================
# PRODUKT AUS JIRA ERMITTELN
# ==================================================
# ==================================================
# PRODUKTNORMALISIERUNG
# ==================================================
PRODUCT_ALIASES = {
# Spam Control
"spam control": "SpamControl",
"spamcontrol": "SpamControl",
"spam-control": "SpamControl",
# Mailversand Basic
"Mailversand Basic": "Mailversand Basic",
"mailversand basic": "Mailversand Basic",
"mailversand-basic": "Mailversand Basic",
"mail basic": "Mailversand Basic",
# Mailversand Pro
"Mailversand Pro": "Mailversand Pro",
"mailversand pro": "Mailversand Pro",
"mailversand-pro": "Mailversand Pro",
"mail pro": "Mailversand Pro",
# Domain Protection
"Domain Protection": "Domain Protection",
"domain protection": "Domain Protection",
"domain-protection": "Domain Protection",
"domainprotect": "Domain Protection",
# VIP Support
"VIP Support": "VIP Support",
"vip support": "VIP Support",
"vip-support": "VIP Support",
"priority support": "VIP Support",
# Wp Premium Care
"WP Premium Care Basic ": "WP Premium Care Basic",
"WP Premium Care Premium": "WP Premium Care Premium",
"WP Premium Care Professional": "WP Premium Care Professional"
}
def normalize_product(product):
if not product:
return None
key = (
product
.strip()
.lower()
)
return PRODUCT_ALIASES.get(
key,
product.strip()
)
def extract_product(text):
lower = text.lower()
#
# Produkt-ID hat Vorrang
#
if "(6051)" in text:
return "SpamControl"
if "(6052)" in text:
return "Mailversand Basic"
if "(6053)" in text:
return "Mailversand Pro"
if "(6057)" in text:
return "Domain Protection"
if "(6054)" in text:
return "WP Premium Care Basic"
if "(6055)" in text:
return "WP Premium Care Premium"
if "(6056)" in text:
return "WP Premium Care Professional"
#
# Fallback auf Namen
#
for alias, canonical in PRODUCT_ALIASES.items():
if alias in lower:
return canonical
return None
# ==================================================
# JIRA API
# ==================================================
def search_issues():
url = (
f"{JIRA_BASE_URL}"
"/rest/api/3/search/jql"
)
payload = {
"jql": JQL_QUERY,
"maxResults": 500,
"fields": [
"summary",
"status",
"description",
"created"
]
}
response = requests.post(
url,
headers=HEADERS,
json=payload
)
response.raise_for_status()
return response.json().get(
"issues",
[]
)
# ==================================================
# CSV LADEN
# ==================================================
activation_data = {}
with open(
INPUT_CSV,
newline="",
encoding="utf-8"
) as f:
reader = csv.DictReader(f)
for row in reader:
normalized_product = normalize_product(
row["product"]
)
key = (
row["customer_no"].strip(),
normalized_product
)
activation_data[key] = row
print(
f"{len(activation_data)} "
"Aktivierungsdatensätze geladen."
)
# ==================================================
# JIRA TICKETS HOLEN
# ==================================================
print("Lade Jira-Tickets...")
issues = search_issues()
print(f"{len(issues)} Tickets gefunden.")
merged = []
for issue in issues:
jira_key = issue["key"]
status = (
issue["fields"]["status"]["name"]
)
summary = (
issue["fields"]
.get("summary", "")
)
description = (
issue["fields"]
.get("description")
)
description_text = (
adf_to_text(description)
)
search_text = (
summary
+ "\n"
+ description_text
)
customer_no = extract_customer_number(
search_text
)
product = extract_product(
search_text
)
if not customer_no:
print(
f"[WARN] Keine Kundennummer "
f"gefunden: {jira_key}"
)
continue
if not product:
print(
f"[WARN] Kein Produkt "
f"gefunden: {jira_key}"
)
continue
match_key = (
customer_no.strip(),
normalize_product(product)
)
if match_key not in activation_data:
print(
f"[WARN] Kein Match: "
f"{jira_key} -> "
f"{customer_no} / "
f"{product}"
)
continue
activation = activation_data[
match_key
]
merged.append({
"jira": jira_key,
"status": status,
"order_no":
activation["order_no"],
"order_date":
activation["order_date"],
"product":
activation["product"],
"domain":
activation["domain"],
"customer":
activation["customer_name"],
"customer_no":
activation["customer_no"]
})
# ==================================================
# ÄLTESTE ZUERST
# ==================================================
merged.sort(
key=lambda item:
datetime.strptime(
item["order_date"],
"%Y-%m-%d"
)
)
# ==================================================
# MARKDOWN ERZEUGEN
# ==================================================
with open(
OUTPUT_MD,
"w",
encoding="utf-8"
) as md:
md.write(
"# Aktivierungsliste\n\n"
)
md.write(
"Älteste Bestellungen zuerst.\n\n"
)
md.write(
f"Generiert: "
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
)
current_date = None
for item in merged:
if item["order_date"] != current_date:
current_date = item[
"order_date"
]
md.write(
f"\n## {current_date}\n\n"
)
md.write(
"- [ ] "
"Zendesk: __________\n"
f" Jira: {item['jira']}\n"
f" Status: {item['status']}\n"
f" Kunde: {item['customer']}\n"
f" Kundennr.: {item['customer_no']}\n"
f" Produkt: {item['product']}\n"
f" Domain: {item['domain']}\n"
f" Bestellung: {item['order_no']}\n\n"
)
print()
print(
f"{len(merged)} Tickets erfolgreich gematcht."
)
print(
f"Markdown-Datei geschrieben:"
)
print(
f" {OUTPUT_MD}"
)