package com.kamco.cd.training.postgres.core;

import com.kamco.cd.training.postgres.repository.train.ModelTrainMetricsJobRepository;
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class ModelTrainMetricsJobCoreService {

  private final ModelTrainMetricsJobRepository modelTrainMetricsJobRepository;

  public List<ResponsePathDto> getTrainMetricSaveNotYetModelIds() {
    return modelTrainMetricsJobRepository.getTrainMetricSaveNotYetModelIds();
  }

  public ResponsePathDto getTrainMetricSaveNotYetModelId(Long modelId) {
    return modelTrainMetricsJobRepository.getTrainMetricSaveNotYetModelId(modelId);
  }

  public void insertModelMetricsTrain(List<Object[]> batchArgs) {
    modelTrainMetricsJobRepository.insertModelMetricsTrain(batchArgs);
  }

  @Transactional
  public void updateModelMetricsTrainSaveYn(Long modelId, String stepNo) {
    modelTrainMetricsJobRepository.updateModelMetricsTrainSaveYn(modelId, stepNo);
  }

  public void insertModelMetricsValidation(List<Object[]> batchArgs) {
    modelTrainMetricsJobRepository.insertModelMetricsValidation(batchArgs);
  }

  @Transactional
  public void updateModelSelectedBestEpoch(Long modelId, Integer epoch) {
    modelTrainMetricsJobRepository.updateModelSelectedBestEpoch(modelId, epoch);
  }
}
