fix: 修复请求日志丢失、轮询日志显示和开关动画问题 (#450)
* fix(logs): 请求明细 - 隐藏轮询状态查询 * fix(ui): 开关滑块 - 恢复状态位移与过渡动画 * fix(protocol): 声明式任务 - 创建请求生成幂等 UUID * fix(logs): 请求日志 - 辅助状态更新失败时仍保留记录
This commit is contained in:
7 files changed
+116
-6
No files matched your search
@@ -190,8 +190,8 @@ func (r *Repository) HasAPICallLogForTask(taskID string) (bool, error) {
|
||||
}
|
||||
|
||||
func visibleAPICallLogQuery(query *gorm.DB) *gorm.DB {
|
||||
// 视频轮询属于一次生成调用的内部阶段,管理端只展示聚合后的创建主记录。
|
||||
return query.Where("NOT (api_call_logs.capability = ? AND api_call_logs.request_kind IN ?)", "video", []string{"poll", "download"})
|
||||
// 轮询属于一次生成调用的内部状态查询,管理端不单独展示。
|
||||
return query.Where("api_call_logs.request_kind <> ?", "poll")
|
||||
}
|
||||
|
||||
func (r *Repository) VideoAPICallRoot(log model.ApiCallLog) (*model.ApiCallLog, error) {
|
||||
|
||||
@@ -151,3 +151,39 @@ func TestQueryAPICallLogsSearchesFailureFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryAPICallLogsHidesInternalPollStages(t *testing.T) {
|
||||
db, err := gorm.Open(sqlite.Open("file:api-log-visible-stages?mode=memory&cache=shared"), &gorm.Config{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.AutoMigrate(&model.ApiCallLog{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
now := time.Now()
|
||||
logs := []model.ApiCallLog{
|
||||
{ID: "image-create", UserID: "user-1", Capability: "image", RequestKind: "create", CreatedAt: now},
|
||||
{ID: "image-poll", UserID: "user-1", Capability: "image", RequestKind: "poll", CreatedAt: now.Add(time.Second)},
|
||||
{ID: "image-download", UserID: "user-1", Capability: "image", RequestKind: "download", CreatedAt: now.Add(2 * time.Second)},
|
||||
{ID: "video-create", UserID: "user-1", Capability: "video", RequestKind: "create", CreatedAt: now.Add(3 * time.Second)},
|
||||
{ID: "video-poll", UserID: "user-1", Capability: "video", RequestKind: "poll", CreatedAt: now.Add(4 * time.Second)},
|
||||
}
|
||||
if err := db.Create(&logs).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
items, total, err := New(db).QueryAPICallLogs(APICallLogFilter{
|
||||
AnalyticsFilter: AnalyticsFilter{From: now.Add(-time.Hour), To: now.Add(time.Hour)},
|
||||
Page: 1,
|
||||
Limit: 20,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if total != 3 || len(items) != 3 {
|
||||
t.Fatalf("visible logs = total:%d items:%#v, want create and download logs without polls", total, items)
|
||||
}
|
||||
if items[0].ID != "video-create" || items[1].ID != "image-download" || items[2].ID != "image-create" {
|
||||
t.Fatalf("visible logs = %#v, want video-create, image-download, image-create", items)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user