// FailedStage sets the stage to failed (used by ruby script)
FailedStage sets the stage to failed (used by ruby script)
// FailedStage sets the stage to failed ( used by ruby script )
func (s RunnerService) FailedStage(ctx context.Context, r api.StageRequest) (*api.StageResponse, error) {
	logger := s.logger.With(zap.String("runner", r.Runner), zap.Int("stage_id", int(r.StageID)))
	logger.Debug("FailedStage request")
	var stage api.Stage
	if err := s.DB.Preload("Process").
		Preload("SearchAndTag").
		Preload("Exclude").
		Preload("Reload").
		Preload("Populate").
		Preload("Ocr").
		Preload("InApp").
		Preload("SyncDescendants").
		First(&stage, r.StageID).Error; err != nil {
		logger.Error("Cannot get the requested stage", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("did not get requested stage : %v", err)
	}
	logger.Debug("Set stage-status to failed", zap.Int("stage_id", int(r.StageID)))
	avian.SetStatusFailed(&stage)
	if err := s.DB.Save(&stage).Error; err != nil {
		logger.Error("Cannot set stage-status to failed", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("cannot to update stage to failed: %v", err)
	}
	logger.Info("FAILED STAGE", zap.String("stage", avian.Name(&stage)))
	return &api.StageResponse{Stage: stage}, nil
}
func ( s RunnerService ) FailedStage ( ctx context . Context , r api . StageRequest ) ( * api . StageResponse , error ) { logger := s . logger . With ( zap . String ( " " , r . Runner ) , zap . Int ( " " , int ( r . StageID ) ) ) logger . Debug ( " " ) var stage api . Stage if err := s . DB . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . Preload ( " " ) . First ( & stage , r . StageID ) . Error ; err != nil { logger . Error ( " " , zap . String ( " " , err . Error ( ) ) ) return nil , fmt . Errorf ( " " , err ) } logger . Debug ( " " , zap . Int ( " " , int ( r . StageID ) ) ) avian . SetStatusFailed ( & stage ) if err := s . DB . Save ( & stage ) . Error ; err != nil { logger . Error ( " " , zap . String ( " " , err . Error ( ) ) ) return nil , fmt . Errorf ( " " , err ) } logger . Info ( " " , zap . String ( " " , avian . Name ( & stage ) ) ) return & api . StageResponse { Stage : stage } , nil }
FailedStage sets the stage to failed (used by ruby script)
FailedStage sets the stage to failed ( used by ruby script )