(_ context.Context, jobID int64)
| 116 | } |
| 117 | |
| 118 | func (s *sqlDatabase) DeleteJob(_ context.Context, jobID int64) error { |
| 119 | var removedJob params.Job |
| 120 | |
| 121 | err := s.conn.Transaction(func(tx *gorm.DB) error { |
| 122 | var workflowJob WorkflowJob |
| 123 | q := tx.Where("workflow_job_id = ?", jobID).Preload("Instance").First(&workflowJob) |
| 124 | if q.Error != nil { |
| 125 | if errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 126 | return nil |
| 127 | } |
| 128 | return fmt.Errorf("error fetching job: %w", q.Error) |
| 129 | } |
| 130 | |
| 131 | var err error |
| 132 | removedJob, err = sqlWorkflowJobToParamsJob(workflowJob) |
| 133 | if err != nil { |
| 134 | return fmt.Errorf("error converting job: %w", err) |
| 135 | } |
| 136 | |
| 137 | q = tx.Delete(&workflowJob) |
| 138 | if q.Error != nil { |
| 139 | if errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 140 | return nil |
| 141 | } |
| 142 | return fmt.Errorf("error deleting job: %w", q.Error) |
| 143 | } |
| 144 | return nil |
| 145 | }) |
| 146 | if err != nil { |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | if removedJob.ID != 0 { |
| 151 | if notifyErr := s.sendNotify(common.JobEntityType, common.DeleteOperation, removedJob); notifyErr != nil { |
| 152 | slog.With(slog.Any("error", notifyErr)).Error("failed to send notify") |
| 153 | } |
| 154 | } |
| 155 | return nil |
| 156 | } |
| 157 | |
| 158 | func (s *sqlDatabase) LockJob(_ context.Context, jobID int64, entityID string) error { |
| 159 | entityUUID, err := uuid.Parse(entityID) |
nothing calls this directly
no test coverage detected