feat: click 'x个方案' to open latest plan detail

This commit is contained in:
hmo
2026-04-28 16:49:57 +08:00
parent 9ea39b7c84
commit b0196ba177
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -139,6 +139,10 @@ class Student(db.Model):
goal_count = len(self.goal_records) if self.goal_records else 0
completed_goal_count = sum(1 for g in self.goal_records if g.achievement_date) if self.goal_records else 0
# 获取最新方案ID
latest_plan = self.plans.order_by(db.desc("created_at")).first()
latest_plan_id = latest_plan.id if latest_plan else None
return {
"id": self.id,
"name": self.name,
@@ -154,6 +158,7 @@ class Student(db.Model):
"problem_count": self.problems.count(),
"problem_names": problem_names, # 问题名称列表(按严重程度排序)
"plan_count": self.plans.count(),
"latest_plan_id": latest_plan_id,
"goal_count": goal_count,
"completed_goal_count": completed_goal_count,
}