feat: Enhanced CE schema and Notion sync (Pains/Gains)
This commit is contained in:
75
scripts/add_manual_report.py
Normal file
75
scripts/add_manual_report.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
# Configuration
|
||||
NOTION_TOKEN = "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"
|
||||
PAGE_ID = "2ff88f42854480008314c9013414d1d0"
|
||||
BERLIN_TZ = ZoneInfo("Europe/Berlin")
|
||||
|
||||
def add_status_to_notion():
|
||||
headers = {
|
||||
"Authorization": f"Bearer {NOTION_TOKEN}",
|
||||
"Content-Type": "application/json",
|
||||
"Notion-Version": "2022-06-28"
|
||||
}
|
||||
|
||||
# 1. Update the 'Total Duration (h)' field
|
||||
# First, get current value
|
||||
resp = requests.get(f"https://api.notion.com/v1/pages/{PAGE_ID}", headers=headers)
|
||||
page_data = resp.json()
|
||||
current_hours = page_data.get("properties", {}).get("Total Duration (h)", {}).get("number") or 0.0
|
||||
new_hours = current_hours + 3.2
|
||||
|
||||
# Update property
|
||||
update_payload = {
|
||||
"properties": {
|
||||
"Total Duration (h)": {"number": new_hours},
|
||||
"Status": {"status": {"name": "Doing"}}
|
||||
}
|
||||
}
|
||||
requests.patch(f"https://api.notion.com/v1/pages/{PAGE_ID}", headers=headers, json=update_payload)
|
||||
|
||||
# 2. Append the Status Update Block
|
||||
timestamp = datetime.now(BERLIN_TZ).strftime('%Y-%m-%d %H:%M')
|
||||
report_content = (
|
||||
"Investierte Zeit in dieser Session: 03:12\n"
|
||||
"Neuer Status: Doing\n\n"
|
||||
"Arbeitszusammenfassung:\n"
|
||||
"Wir haben heute den entscheidenden technischen Durchbruch bei der bidirektionalen Datensynchronisation zwischen dem Company Explorer (CE) und SuperOffice CRM (SO) erzielt.\n\n"
|
||||
"1. Infrastruktur-Stabilisierung: Das Git-Repository wurde über eine interne Docker-Netzwerk-Verbindung (gitea-internal) stabil angebunden.\n"
|
||||
"2. Pipeline-Durchstich (SO -> CE): Firmenstammdaten aus SuperOffice (Contact ID 2) werden sauber in den Company Explorer übertragen.\n"
|
||||
"3. Round-Trip & Write-Back (CE -> SO): Das Protokoll für den Rückschreibeprozess wurde geknackt. Erkenntnis: SuperOffice ignoriert UrlAddress beim PUT, wir nutzen jetzt das Urls-Array. Pflichtfelder wie Number2 werden nun explizit mitgegeben."
|
||||
)
|
||||
|
||||
block_payload = {
|
||||
"children": [
|
||||
{
|
||||
"object": "block",
|
||||
"type": "heading_2",
|
||||
"heading_2": {
|
||||
"rich_text": [{"type": "text", "text": {"content": f"🤖 Status-Update ({timestamp} Berlin Time)"}}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"object": "block",
|
||||
"type": "code",
|
||||
"code": {
|
||||
"rich_text": [{"type": "text", "text": {"content": report_content}}],
|
||||
"language": "yaml"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
final_resp = requests.patch(f"https://api.notion.com/v1/blocks/{PAGE_ID}/children", headers=headers, json=block_payload)
|
||||
|
||||
if final_resp.status_code == 200:
|
||||
print(f"✅ SUCCESS: Notion Task updated. Total hours now: {new_hours}")
|
||||
else:
|
||||
print(f"❌ ERROR: {final_resp.text}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
add_status_to_notion()
|
||||
Reference in New Issue
Block a user