Files
Brancheneinstufung2/debug_notion_search.py
Floke 4afadc2c26 fix(transcription): [2f388f42] finalize and fix AI insights feature
This commit resolves all outstanding issues with the AI Insights feature.

- Corrects the transcript formatting logic in  to properly handle the database JSON structure, ensuring the AI receives the correct context.
- Fixes the Gemini API client by using the correct model name ('gemini-2.0-flash') and the proper client initialization.
- Updates  to securely pass the API key as an environment variable to the container.
- Cleans up the codebase by removing temporary debugging endpoints.
- Adds  script for programmatic updates.
- Updates documentation with troubleshooting insights from the implementation process.
2026-01-26 08:53:13 +00:00

64 lines
2.3 KiB
Python

import requests
import json
from getpass import getpass
def debug_search_databases():
print("--- Notion Datenbank Such-Debugger ---")
token = getpass("Bitte gib deinen Notion API Key ein (Eingabe wird nicht angezeigt): ")
if not token:
print("\nFehler: Kein Token eingegeben. Abbruch.")
return
print("\n... Sende Suchanfrage an Notion für alle Datenbanken...")
url = "https://api.notion.com/v1/search"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
"Notion-Version": "2022-06-28"
}
payload = {
"filter": {
"value": "database",
"property": "object"
},
"sort": {
"direction": "ascending",
"timestamp": "last_edited_time"
}
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status() # Hebt HTTPError für 4xx/5xx Statuscodes hervor
results = response.json().get("results", [])
if not results:
print("\nKeine Datenbanken gefunden, auf die die Integration Zugriff hat.")
print("Bitte stelle sicher, dass die Integration auf Top-Level-Seiten geteilt ist.")
return
print(f"\nGefundene Datenbanken ({len(results)} insgesamt):")
print("--------------------------------------------------")
for db in results:
db_id = db["id"]
db_title_parts = db.get("title", [])
db_title = db_title_parts[0].get("plain_text", "(Unbenannt)") if db_title_parts else "(Unbenannt)"
print(f"Titel: '{db_title}'\n ID: {db_id}\n")
print("--------------------------------------------------")
print("Bitte überprüfe die genauen Titel und IDs für 'Projects' und 'All Tasks'.")
except requests.exceptions.RequestException as e:
print(f"\n❌ FEHLER! Fehler bei der Suche nach Datenbanken: {e}")
if hasattr(e, 'response') and e.response is not None:
print(f"HTTP Status Code: {e.response.status_code}")
try:
print(f"Antwort des Servers: {json.dumps(e.response.json(), indent=2)}")
except:
print(f"Antwort des Servers: {e.response.text}")
if __name__ == "__main__":
debug_search_databases()