From 488542337d2c217733f2ea0e29d90a035b955ccd Mon Sep 17 00:00:00 2001 From: Floke Date: Mon, 9 Mar 2026 02:29:37 +0000 Subject: [PATCH] [31e88f42] Add weekly summary generation script for Notion tasks --- scripts/generate_weekly_summary.py | 174 +++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 scripts/generate_weekly_summary.py diff --git a/scripts/generate_weekly_summary.py b/scripts/generate_weekly_summary.py new file mode 100644 index 00000000..c413cceb --- /dev/null +++ b/scripts/generate_weekly_summary.py @@ -0,0 +1,174 @@ +import os +import re +import datetime +from typing import List, Dict, Tuple +from dotenv import load_dotenv + +import sys +# Make dev_session from /app available +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from dev_session import find_database_by_title, query_notion_database, get_page_content, get_page_title + +def parse_time(time_str: str) -> float: + """Parses 'HH:MM' into decimal hours.""" + try: + hours, minutes = map(int, time_str.split(':')) + return hours + (minutes / 60.0) + except: + return 0.0 + +def format_time(decimal_hours: float) -> str: + hours = int(decimal_hours) + minutes = int(round((decimal_hours - hours) * 60)) + if minutes == 60: + hours += 1 + minutes = 0 + return f"{hours:02d}:{minutes:02d}" + +def extract_status_updates(content: str, cutoff_date: datetime.datetime) -> List[Dict]: + """ + Extracts status updates from the markdown content. + Looks for: ## πŸ€– Status-Update (YYYY-MM-DD HH:MM Berlin Time) + """ + updates = [] + # Pattern to match the heading and the subsequent code block + pattern = r"## πŸ€– Status-Update \((?P\d{4}-\d{2}-\d{2}) (?P