feat: 添加日记草稿生成脚本 + 今日进展更新
- 新增 generate_diary_draft.py - 基于任务进展生成日记草稿 - 新增 update_today_progress.py - 更新任务进展和经验总结 - 完成任务管理功能(100%) - 完成功能完善任务(100%) - 添加 3 条经验总结(Tab 设计、任务中心交互、混合记录策略)
This commit is contained in:
89
generate_diary_draft.py
Normal file
89
generate_diary_draft.py
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
生成日记草稿 - 基于当天的任务进展
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import django
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'diary_system.settings')
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
|
||||
django.setup()
|
||||
|
||||
from diary.models import Task, DiaryEntry, Experience
|
||||
from django.utils import timezone
|
||||
|
||||
def generate_draft():
|
||||
yesterday = timezone.now().date() - timedelta(days=1)
|
||||
yesterday_str = yesterday.strftime('%Y-%m-%d')
|
||||
|
||||
print(f"📝 生成 {yesterday_str} 的日记草稿\n")
|
||||
print("=" * 60)
|
||||
|
||||
# 获取昨天创建或更新的任务
|
||||
tasks_updated = Task.objects.filter(updated_at__date=yesterday)
|
||||
|
||||
# 检查是否已有日记
|
||||
existing_entry = DiaryEntry.objects.filter(date=yesterday).first()
|
||||
|
||||
if existing_entry:
|
||||
print(f"⚠️ {yesterday_str} 已有日记:")
|
||||
print(f" 标题:{existing_entry.title}")
|
||||
print(f" 更新:{existing_entry.updated_at}")
|
||||
return
|
||||
|
||||
print(f"✅ 任务进展 ({tasks_updated.count()} 个任务有更新):\n")
|
||||
|
||||
completed_tasks = []
|
||||
in_progress_tasks = []
|
||||
|
||||
for task in tasks_updated:
|
||||
if task.status == 'completed':
|
||||
completed_tasks.append(task)
|
||||
elif task.status == 'in_progress':
|
||||
in_progress_tasks.append(task)
|
||||
|
||||
print(f" • {task.title}")
|
||||
print(f" 状态:{task.get_status_display()} | 进展:{task.progress_percent}%")
|
||||
if task.progress_notes:
|
||||
notes = task.progress_notes.split('\n')[:3]
|
||||
for note in notes:
|
||||
if note.strip():
|
||||
print(f" → {note[:80]}...")
|
||||
print()
|
||||
|
||||
print("=" * 60)
|
||||
print("\n📋 日记草稿建议:\n")
|
||||
|
||||
# 完成的任务
|
||||
if completed_tasks:
|
||||
print("✅ 完成的任务:")
|
||||
for task in completed_tasks:
|
||||
print(f" - {task.title}")
|
||||
print()
|
||||
|
||||
# 学到的东西(从任务描述推断)
|
||||
if in_progress_tasks:
|
||||
print("📚 可能学到的东西:")
|
||||
for task in in_progress_tasks:
|
||||
if task.description:
|
||||
print(f" - {task.title[:50]}...")
|
||||
print()
|
||||
|
||||
# 建议
|
||||
print("💡 建议记录:")
|
||||
print(f" - 今天完成了 {len(completed_tasks)} 个任务")
|
||||
print(f" - 推进了 {len(in_progress_tasks)} 个进行中的任务")
|
||||
print(f" - 总任务完成率:{Task.objects.filter(status='completed').count()}/{Task.objects.count()}")
|
||||
print()
|
||||
print("=" * 60)
|
||||
|
||||
return {
|
||||
'date': yesterday_str,
|
||||
'completed_tasks': completed_tasks,
|
||||
'in_progress_tasks': in_progress_tasks,
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate_draft()
|
||||
Reference in New Issue
Block a user