feat(*): 创作工作台 - 完善媒体上传预览与连线交互并修复任务章节及日志筛选

This commit is contained in:
ddCat committed 2026-09-08 17:26:34 +08:00
1 parent 95b004ec0f
commit 068a8daea6
56 files changed
+3316 -274

No files matched your search

@@ -18,6 +18,45 @@ type sqlCaptureLogger struct {
statements []string
}
func TestAPICallLogRecordTypeFiltersListAndExport(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file:api-log-record-types?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()
for _, item := range []model.ApiCallLog{
{ID: "request", Capability: "video", RequestKind: "create", CreatedAt: now},
{ID: "poll", Capability: "video", RequestKind: "poll", CreatedAt: now},
{ID: "video-download", Capability: "video", RequestKind: "download", CreatedAt: now},
{ID: "image-download", Capability: "image", RequestKind: "download", CreatedAt: now},
} {
if err := db.Create(&item).Error; err != nil {
t.Fatal(err)
}
}
repo := New(db)
for _, tc := range []struct {
kind string
count int
}{{"", 1}, {"request", 1}, {"download", 2}, {"all", 4}} {
filter := APICallLogFilter{AnalyticsFilter: AnalyticsFilter{From: now.Add(-time.Hour), To: now.Add(time.Hour)}, RecordType: tc.kind}
logs, total, err := repo.QueryAPICallLogs(filter)
if err != nil {
t.Fatal(err)
}
if len(logs) != tc.count || total != int64(tc.count) {
t.Fatalf("kind=%s: count=%d total=%d", tc.kind, len(logs), total)
}
exported, err := repo.ExportAPICallLogs(filter, 100)
if err != nil || len(exported) != tc.count {
t.Fatalf("kind=%s: export count=%d err=%v", tc.kind, len(exported), err)
}
}
}
func (l *sqlCaptureLogger) LogMode(logger.LogLevel) logger.Interface { return l }
func (*sqlCaptureLogger) Info(context.Context, string, ...any) {}
func (*sqlCaptureLogger) Warn(context.Context, string, ...any) {}