Fix: 진행 상황 보고
This commit is contained in:
parent
a0c1bf7c2b
commit
ea47a7cb39
@ -12,7 +12,8 @@ public interface AiModelRepository extends JpaRepository<AiModel, Integer> {
|
||||
|
||||
@Query("SELECT a FROM AiModel a " +
|
||||
"WHERE a.project IS NULL " +
|
||||
"OR a.project.id = :projectId ")
|
||||
"OR a.project.id = :projectId " +
|
||||
"ORDER BY a.id DESC ")
|
||||
List<AiModel> findAllByProjectId(@Param("projectId") Integer projectId);
|
||||
|
||||
@Query("SELECT a FROM AiModel a " +
|
||||
|
@ -60,6 +60,7 @@ public class AiModelService {
|
||||
public List<AiModelResponse> getModelList(final Integer projectId) {
|
||||
Project project = getProject(projectId);
|
||||
int progressModelId = progressService.getProgressModelByProjectId(projectId);
|
||||
log.debug("진행 중 modelId{} {} ",progressModelId, projectId);
|
||||
return aiModelRepository.findAllByProjectId(projectId)
|
||||
.stream()
|
||||
.map(o -> AiModelResponse.of(o, progressModelId, project.getProjectType()))
|
||||
|
@ -65,8 +65,11 @@ public class ProgressCacheRepository {
|
||||
public int getProgressModelId(final int projectId) {
|
||||
String key = CacheKey.autoLabelingProgressKey();
|
||||
Object modelId = redisTemplate.opsForHash().get(key, String.valueOf(projectId));
|
||||
log.debug("projectId {} {}", projectId, modelId);
|
||||
return modelId == null ? 0 : (int) modelId;
|
||||
log.debug("projectId {} key {}", projectId, modelId);
|
||||
if (modelId == null) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt((String) modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,8 +27,8 @@ public class ReportController {
|
||||
@SwaggerApiSuccess(description = "완성된 모델 리포트를 조회합니다.")
|
||||
@SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR})
|
||||
@GetMapping("/models/{model_id}")
|
||||
public List<ReportResponse> getReportsByModelId(@PathVariable("model_id") final Integer modelId, @PathVariable("project_id") final Integer projectId) {
|
||||
return reportService.getReportsByModelId(projectId,modelId);
|
||||
public ReportResponse getReportsByModelId(@PathVariable("model_id") final Integer modelId) {
|
||||
return reportService.getReportsByModelId(modelId);
|
||||
}
|
||||
|
||||
@Operation(summary = "학습중인 모델 리포트를 조회합니다.", description = "학습중인 모델 리포트를 조회합니다.")
|
||||
|
@ -4,8 +4,9 @@ import com.worlabel.domain.report.entity.Report;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ReportRepository extends JpaRepository<Report, Integer> {
|
||||
|
||||
List<Report> findByAiModelId(Integer modelId);
|
||||
Optional<Report> findByAiModelId(Integer modelId);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import com.worlabel.domain.report.entity.Report;
|
||||
import com.worlabel.domain.report.entity.dto.ReportRequest;
|
||||
import com.worlabel.domain.report.entity.dto.ReportResponse;
|
||||
import com.worlabel.domain.report.repository.ReportRepository;
|
||||
import com.worlabel.global.exception.CustomException;
|
||||
import com.worlabel.global.exception.ErrorCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,10 +27,10 @@ public class ReportService {
|
||||
private final ReportRepository reportRepository;
|
||||
private final ProgressService progressService;
|
||||
|
||||
public List<ReportResponse> getReportsByModelId(final Integer projectId, final Integer modelId) {
|
||||
return reportRepository.findByAiModelId(modelId).stream()
|
||||
.map(ReportResponse::from)
|
||||
.toList();
|
||||
public ReportResponse getReportsByModelId(final Integer modelId) {
|
||||
Report report = reportRepository.findByAiModelId(modelId)
|
||||
.orElseThrow(() -> new CustomException(ErrorCode.DATA_NOT_FOUND));
|
||||
return ReportResponse.from(report);
|
||||
}
|
||||
|
||||
public void addReportByModelId(final Integer projectId, final Integer modelId, final ReportRequest reportRequest) {
|
||||
|
Loading…
Reference in New Issue
Block a user