修复 LatestJob 排序并显示任务 ID

This commit is contained in:
2026-07-04 12:18:21 +08:00
parent 7f300b9067
commit d497eb7f96
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -198,7 +198,7 @@ func (s *StockSyncService) LatestJob(ctx context.Context) (*models.StockSyncJob,
var job models.StockSyncJob var job models.StockSyncJob
if err := s.db.WithContext(ctx). if err := s.db.WithContext(ctx).
Where("started_at > ?", time.Time{}). Where("started_at > ?", time.Time{}).
Order("started_at DESC"). Order("started_at DESC, id DESC").
First(&job).Error; err != nil { First(&job).Error; err != nil {
if err == gorm.ErrRecordNotFound { if err == gorm.ErrRecordNotFound {
return nil, nil return nil, nil
+2 -2
View File
@@ -276,7 +276,7 @@ function formatSyncStatus(job: SyncJob): string {
} }
const statusText = job.status === 'success' ? '成功' : '失败' const statusText = job.status === 'success' ? '成功' : '失败'
if (job.status === 'failed' && job.error_message) { if (job.status === 'failed' && job.error_message) {
return `${statusText} · ${timeStr} · ${job.error_message}` return `${statusText} · ${timeStr} · ${job.error_message} · ${job.id.slice(0, 8)}`
} }
return `${statusText} · ${timeStr}` return `${statusText} · ${timeStr} · ${job.id.slice(0, 8)}`
} }