fix(backend): keep workspace completion metadata honest
This commit is contained in:
@@ -17,27 +17,6 @@ type workspaceCounts struct {
|
||||
cronPlans int64
|
||||
}
|
||||
|
||||
// Dashboard 保留旧概览查询给尚未迁移的 handler;所有统计仍严格限定项目所有者。
|
||||
func (s *Service) Dashboard(ownerID uint, projectID uint) (Dashboard, error) {
|
||||
if err := ensureProjectOwner(ownerID, projectID); err != nil {
|
||||
return Dashboard{}, err
|
||||
}
|
||||
dashboard := Dashboard{ProjectID: projectID}
|
||||
if err := models.DBService.Model(&models.SenlinAgentInboxItem{}).Where("project_id = ? AND status = ?", projectID, "open").Count(&dashboard.PendingInboxCount).Error; err != nil {
|
||||
return dashboard, err
|
||||
}
|
||||
if err := models.DBService.Model(&models.SenlinAgentTask{}).Where("project_id = ? AND status <> ?", projectID, "done").Count(&dashboard.OpenTaskCount).Error; err != nil {
|
||||
return dashboard, err
|
||||
}
|
||||
if err := models.DBService.Model(&models.SenlinAgentNote{}).Where("project_id = ?", projectID).Count(&dashboard.RecentNoteCount).Error; err != nil {
|
||||
return dashboard, err
|
||||
}
|
||||
if err := models.DBService.Model(&models.SenlinAgentAISession{}).Where("project_id = ?", projectID).Count(&dashboard.RecentSessionCount).Error; err != nil {
|
||||
return dashboard, err
|
||||
}
|
||||
return dashboard, nil
|
||||
}
|
||||
|
||||
// Workspace 在确认项目归属后执行首屏聚合;后续子查询只接收已授权的内部主键。
|
||||
func (s *Service) Workspace(ownerID uint, projectIdentity string) (WorkspaceDTO, error) {
|
||||
project, err := FindOwnedProject(ownerID, projectIdentity)
|
||||
@@ -191,14 +170,10 @@ func (s *Service) workspaceTasks(projectID uint, projectIdentity string) ([]Work
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
completed := task.Status == "done"
|
||||
var completedAt *time.Time
|
||||
if completed {
|
||||
completedAt = utcOptionalTime(&task.UpdatedAt)
|
||||
}
|
||||
// 当前模型没有真实完成时间字段,不能用更新时间伪装;CompletedAt 保持 nil。
|
||||
item := WorkspaceTaskDTO{
|
||||
ID: task.Identity, ProjectID: projectIdentity, Title: task.Title, Summary: task.Description,
|
||||
Completed: completed, Owner: owner, Due: utcOptionalTime(task.DueAt), CreatedAt: task.CreatedAt.UTC(), CompletedAt: completedAt,
|
||||
Completed: task.Status == "done", Owner: owner, Due: utcOptionalTime(task.DueAt), CreatedAt: task.CreatedAt.UTC(),
|
||||
}
|
||||
if tag, ok := tags[task.ID]; ok {
|
||||
item.TagID = &tag.ID
|
||||
|
||||
Reference in New Issue
Block a user