[31e88f42] Add global executive highlights at the top of the weekly summary report
This commit is contained in:
@@ -63,6 +63,49 @@ def extract_status_updates(content: str, cutoff_date: datetime.datetime) -> List
|
||||
|
||||
return updates
|
||||
|
||||
def generate_global_executive_summary(api_key: str, all_project_summaries: str) -> str:
|
||||
"""Uses Gemini REST API to extract the top global highlights of the week."""
|
||||
if not api_key:
|
||||
return ""
|
||||
|
||||
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key={api_key}"
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
|
||||
prompt = f"""
|
||||
Du bist der CTO, der am Montagmorgen ein kurzes Management-Briefing (Executive Summary) für die Geschäftsführung gibt.
|
||||
Hier sind die bereits aufbereiteten Meilensteine aller Projekte der letzten Woche:
|
||||
|
||||
<projekte>
|
||||
{all_project_summaries}
|
||||
</projekte>
|
||||
|
||||
Deine Aufgabe:
|
||||
Fasse die 3 bis maximal 5 ABSOLUT WICHTIGSTEN, übergreifenden "Major Milestones" und Fortschritte der *gesamten Woche* extrem komprimiert und stichpunktartig zusammen.
|
||||
Fokussiere dich auf den echten "Business Value", ausgelieferte Features oder große technische Durchbrüche.
|
||||
|
||||
Verwende folgendes Format (starte direkt mit den Bullet-Points):
|
||||
- 🚀 **[Kurzer Titel/Projekt]**: [1 Satz mit dem Kern-Ergebnis]
|
||||
- 💡 **[Erkenntnis/Entscheidung]**: [1 Satz]
|
||||
- ...
|
||||
|
||||
Schreibe keinen einleitenden Text und kein Fazit. Nur diese prägnanten, professionellen Bullet-Points.
|
||||
"""
|
||||
|
||||
payload = {
|
||||
"contents": [{"parts": [{"text": prompt}]}],
|
||||
"generationConfig": {"temperature": 0.2}
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=30)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
summary = data['candidates'][0]['content']['parts'][0]['text']
|
||||
return summary.strip()
|
||||
except Exception as e:
|
||||
print(f"Fehler bei der globalen Executive Summary: {e}")
|
||||
return ""
|
||||
|
||||
def summarize_with_gemini(api_key: str, project_name: str, total_hours: float, raw_updates: str) -> str:
|
||||
"""Uses Gemini REST API to summarize the project updates."""
|
||||
if not api_key:
|
||||
@@ -211,7 +254,34 @@ def main():
|
||||
report_data[project_name]["invested_hours"] += update["invested_hours"]
|
||||
report_data[project_name]["tasks"][task_name].append(update)
|
||||
|
||||
# 3. Generate Markdown Report (AI Summarized)
|
||||
if not report_data:
|
||||
print("Keine Status-Updates in den letzten 7 Tagen gefunden.")
|
||||
return
|
||||
|
||||
# 3. Process Individual Project Summaries
|
||||
project_summaries = {}
|
||||
for project_name, p_data in sorted(report_data.items(), key=lambda x: x[1]['invested_hours'], reverse=True):
|
||||
print(f"Fasse zusammen (AI): {project_name} ...")
|
||||
|
||||
raw_updates_text = ""
|
||||
for task_name, updates in p_data["tasks"].items():
|
||||
raw_updates_text += f"\nTASK: {task_name}\n"
|
||||
for update in sorted(updates, key=lambda x: x['date']):
|
||||
raw_updates_text += f"UPDATE ({update['date']}):\n{update['summary']}\n"
|
||||
|
||||
ai_summary = summarize_with_gemini(gemini_key, project_name, p_data['invested_hours'], raw_updates_text)
|
||||
project_summaries[project_name] = ai_summary
|
||||
|
||||
|
||||
# 4. Generate Global Executive Summary
|
||||
print("Erstelle globale Executive Summary...")
|
||||
combined_summaries = ""
|
||||
for proj_name, summ in project_summaries.items():
|
||||
combined_summaries += f"\nProjekt: {proj_name}\n{summ}\n"
|
||||
|
||||
global_executive_summary = generate_global_executive_summary(gemini_key, combined_summaries)
|
||||
|
||||
# 5. Build Markdown Report
|
||||
report_lines = []
|
||||
report_lines.append(f"# 📊 Executive Weekly Summary ({cutoff_date.strftime('%Y-%m-%d')} bis {now.strftime('%Y-%m-%d')})")
|
||||
report_lines.append("")
|
||||
@@ -220,33 +290,28 @@ def main():
|
||||
report_lines.append(f"**Gesamte investierte Zeit der Woche:** {format_time(total_hours)}")
|
||||
report_lines.append("")
|
||||
|
||||
if not report_data:
|
||||
report_lines.append("*Keine Status-Updates in den letzten 7 Tagen gefunden.*")
|
||||
else:
|
||||
# Add Graphical time distribution
|
||||
report_lines.append("## ⏱️ Zeitverteilung & Fokus")
|
||||
report_lines.append(generate_mermaid_pie(report_data))
|
||||
report_lines.append("\n<details><summary>Text-basierte Zeitverteilung (Fallback)</summary>\n")
|
||||
report_lines.append(generate_ascii_bar_chart(report_data))
|
||||
report_lines.append("\n</details>\n")
|
||||
report_lines.append("---")
|
||||
# Global Summary
|
||||
if global_executive_summary:
|
||||
report_lines.append("## 🌟 Top Highlights der Woche")
|
||||
report_lines.append(global_executive_summary)
|
||||
report_lines.append("\n---")
|
||||
report_lines.append("")
|
||||
|
||||
for project_name, p_data in sorted(report_data.items(), key=lambda x: x[1]['invested_hours'], reverse=True):
|
||||
print(f"Fasse zusammen (AI): {project_name} ...")
|
||||
report_lines.append(f"## 📁 {project_name} ({format_time(p_data['invested_hours'])})")
|
||||
|
||||
# Combine all raw texts for the project to send to Gemini
|
||||
raw_updates_text = ""
|
||||
for task_name, updates in p_data["tasks"].items():
|
||||
raw_updates_text += f"\nTASK: {task_name}\n"
|
||||
for update in sorted(updates, key=lambda x: x['date']):
|
||||
raw_updates_text += f"UPDATE ({update['date']}):\n{update['summary']}\n"
|
||||
|
||||
ai_summary = summarize_with_gemini(gemini_key, project_name, p_data['invested_hours'], raw_updates_text)
|
||||
report_lines.append(ai_summary)
|
||||
report_lines.append("\n---")
|
||||
report_lines.append("")
|
||||
# Graphical time distribution
|
||||
report_lines.append("## ⏱️ Zeitverteilung & Fokus")
|
||||
report_lines.append(generate_mermaid_pie(report_data))
|
||||
report_lines.append("\n<details><summary>Text-basierte Zeitverteilung (Fallback)</summary>\n")
|
||||
report_lines.append(generate_ascii_bar_chart(report_data))
|
||||
report_lines.append("\n</details>\n")
|
||||
report_lines.append("---")
|
||||
report_lines.append("")
|
||||
|
||||
# Individual Projects
|
||||
for project_name, p_data in sorted(report_data.items(), key=lambda x: x[1]['invested_hours'], reverse=True):
|
||||
report_lines.append(f"## 📁 {project_name} ({format_time(p_data['invested_hours'])})")
|
||||
report_lines.append(project_summaries[project_name])
|
||||
report_lines.append("\n---")
|
||||
report_lines.append("")
|
||||
|
||||
report_content = "\n".join(report_lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user