修复看板上次同步时间显示 Invalid Date

This commit is contained in:
2026-07-04 11:58:58 +08:00
parent aa37a93a35
commit ab14eb9c30
2 changed files with 12 additions and 4 deletions
+4 -1
View File
@@ -147,7 +147,10 @@ func (s *StockSyncService) doSync(ctx context.Context) (int, error) {
func (s *StockSyncService) LatestJob(ctx context.Context) (*models.StockSyncJob, error) {
var job models.StockSyncJob
if err := s.db.WithContext(ctx).Order("started_at DESC").First(&job).Error; err != nil {
if err := s.db.WithContext(ctx).
Where("started_at > ?", time.Time{}).
Order("started_at DESC").
First(&job).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return nil, nil
}