# -*- coding: utf-8 -*- """ Created on Wed Jul 23 20:29:03 2025 @author: USER """ from projects import get_project_pages from getDB import find_database_in_page from notion_tasks import extract_tasks import csv def main(): tasks_mirror = [] projects = get_project_pages() #projects = projects[:3] # ⬅️ Limité à 3 projets for page_id, project_name in projects: task_db_id = find_database_in_page(page_id) if task_db_id: tasks = extract_tasks(task_db_id) # Injecter le nom du projet dans chaque tâche tasks = [(name, status, deadline, person, url, project_name) for (name, status, deadline, person, url) in tasks] tasks_mirror.extend(tasks) print(f"✅ {project_name} → {len(tasks)} tâches récupérées") else: print(f"⚠️ Pas de base 'To do' dans {project_name}") print(f"\n📊 Total : {len(tasks_mirror)} tâches dans le miroir.") with open("tasks_export.csv", "w", newline='', encoding="utf-8") as f: writer = csv.writer(f) writer.writerow(["Nom", "Statut", "Deadline", "Responsable", "Lien", "Projet"]) writer.writerows(tasks_mirror) print("✅ Export global terminé → tasks_export.csv") if __name__ == "__main__": main()