Fix: 진행 상황 보고

This commit is contained in:
김용수 2024-09-30 14:49:41 +09:00
parent a0c1bf7c2b
commit ea47a7cb39
6 changed files with 18 additions and 10 deletions

View File

@ -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 " +

View File

@ -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()))

View File

@ -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);
}
/**

View File

@ -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 = "학습중인 모델 리포트를 조회합니다.")

View File

@ -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);
}

View File

@ -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) {