fix(assets): 素材删除 - 排除已结束任务的生成历史引用
This commit is contained in:
1 parent
da0531f6eb
commit
de8e190829
4 files changed
+101
-6
No files matched your search
@@ -17,6 +17,7 @@ type ResourceReferenceDocument struct {
|
||||
Title string
|
||||
PrimaryJSON string
|
||||
SecondaryJSON string
|
||||
TaskStatus model.TaskStatus
|
||||
}
|
||||
|
||||
type ResourceDirectReference struct {
|
||||
@@ -104,11 +105,13 @@ func (r *Repository) ResourceReferenceSnapshot(userID string, excludingAssetID s
|
||||
}
|
||||
|
||||
var tasks []model.Task
|
||||
if err := r.db.Select("id", "prompt", "input_json", "result_json").Where("user_id = ?", userID).Find(&tasks).Error; err != nil {
|
||||
if err := r.db.Select("id", "prompt", "status", "input_json", "result_json").Where("user_id = ?", userID).Find(&tasks).Error; err != nil {
|
||||
return snapshot, err
|
||||
}
|
||||
taskStatuses := make(map[string]model.TaskStatus, len(tasks))
|
||||
for _, task := range tasks {
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务", ID: task.ID, Title: task.Prompt, PrimaryJSON: task.InputJSON, SecondaryJSON: task.ResultJSON})
|
||||
taskStatuses[task.ID] = task.Status
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务", ID: task.ID, Title: task.Prompt, PrimaryJSON: task.InputJSON, SecondaryJSON: task.ResultJSON, TaskStatus: task.Status})
|
||||
}
|
||||
|
||||
var runs []model.CreationRun
|
||||
@@ -127,19 +130,19 @@ func (r *Repository) ResourceReferenceSnapshot(userID string, excludingAssetID s
|
||||
}
|
||||
|
||||
var taskLogs []model.TaskLog
|
||||
if err := r.db.Select("id", "message", "payload").Where("user_id = ?", userID).Find(&taskLogs).Error; err != nil {
|
||||
if err := r.db.Select("id", "task_id", "message", "payload").Where("user_id = ?", userID).Find(&taskLogs).Error; err != nil {
|
||||
return snapshot, err
|
||||
}
|
||||
for _, taskLog := range taskLogs {
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务日志", ID: taskLog.ID, Title: taskLog.Message, PrimaryJSON: taskLog.Payload})
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务日志", ID: taskLog.ID, Title: taskLog.Message, PrimaryJSON: taskLog.Payload, TaskStatus: taskStatuses[taskLog.TaskID]})
|
||||
}
|
||||
|
||||
var results []model.Result
|
||||
if err := r.db.Select("id", "kind", "url", "payload").Where("user_id = ?", userID).Find(&results).Error; err != nil {
|
||||
if err := r.db.Select("id", "task_id", "kind", "url", "payload").Where("user_id = ?", userID).Find(&results).Error; err != nil {
|
||||
return snapshot, err
|
||||
}
|
||||
for _, result := range results {
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务结果", ID: result.ID, Title: result.Kind, PrimaryJSON: result.URL, SecondaryJSON: result.Payload})
|
||||
snapshot.Documents = append(snapshot.Documents, ResourceReferenceDocument{Kind: "任务结果", ID: result.ID, Title: result.Kind, PrimaryJSON: result.URL, SecondaryJSON: result.Payload, TaskStatus: taskStatuses[result.TaskID]})
|
||||
}
|
||||
|
||||
var projects []model.Project
|
||||
|
||||
Reference in new issue
Block a user