From 50e7e1aab84be4690b3376aefed62e556e3c776d Mon Sep 17 00:00:00 2001 From: "gayoun.park" Date: Thu, 18 Dec 2025 17:57:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EB=A1=A0=EA=B4=80=EB=A6=AC=20>=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=EA=B4=80=EB=A6=AC=20=EB=AA=A9=EB=A1=9D=20sco?= =?UTF-8?q?re=20=ED=95=AD=EB=AA=A9=EB=93=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cd/kamcoback/model/dto/ModelMgmtDto.java | 8 ++- .../entity/ModelResultMetricEntity.java | 58 +++++++++++++++++++ .../model/ModelMgmtRepositoryImpl.java | 14 +++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/kamco/cd/kamcoback/postgres/entity/ModelResultMetricEntity.java diff --git a/src/main/java/com/kamco/cd/kamcoback/model/dto/ModelMgmtDto.java b/src/main/java/com/kamco/cd/kamcoback/model/dto/ModelMgmtDto.java index b2fee42b..97830283 100644 --- a/src/main/java/com/kamco/cd/kamcoback/model/dto/ModelMgmtDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/model/dto/ModelMgmtDto.java @@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.model.dto; import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm; import io.swagger.v3.oas.annotations.media.Schema; +import java.math.BigDecimal; import java.time.ZonedDateTime; import lombok.AllArgsConstructor; import lombok.Getter; @@ -69,7 +70,12 @@ public class ModelMgmtDto { private String dockerFileNm; private String modelType; private String createCompleteDttm; - private String recentUseDttm; + private String recentUseDttm; // TODO: 추론관리 테이블 나오면 분석진행중일 때 사용중으로 리턴하기 + private BigDecimal f1Score; + private BigDecimal precision; + private BigDecimal recall; + private BigDecimal accuracy; + private BigDecimal iou; private Boolean deleted; } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/entity/ModelResultMetricEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/ModelResultMetricEntity.java new file mode 100644 index 00000000..37defe6d --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/entity/ModelResultMetricEntity.java @@ -0,0 +1,58 @@ +package com.kamco.cd.kamcoback.postgres.entity; + +import jakarta.persistence.*; +import java.time.ZonedDateTime; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; + +@Entity +@Table(name = "tb_model_result_metric") +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ModelResultMetricEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "metric_uid") + private Long id; + + @Column(name = "model_uid") + private Long modelUid; + + @Column(name = "model_ver_uid") + private Long modelVerUid; + + @JdbcTypeCode(SqlTypes.JSON) + @Column(name = "metrics", columnDefinition = "jsonb") + private Map metrics; + + @Column(name = "f1_score") + private Double f1Score; + + @Column(name = "precision") + private Double precision; + + @Column(name = "recall") + private Double recall; + + @Column(name = "loss") + private Double loss; + + @Column(name = "iou") + private Double iou; + + @Column(name = "created_dttm", updatable = false, nullable = false) + private ZonedDateTime createdDate; + + @PrePersist + protected void onPersist() { + this.createdDate = ZonedDateTime.now(); + } +} diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/model/ModelMgmtRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/model/ModelMgmtRepositoryImpl.java index eda77291..d6b17926 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/model/ModelMgmtRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/model/ModelMgmtRepositoryImpl.java @@ -1,6 +1,7 @@ package com.kamco.cd.kamcoback.postgres.repository.model; import static com.kamco.cd.kamcoback.postgres.entity.QModelMgmtEntity.modelMgmtEntity; +import static com.kamco.cd.kamcoback.postgres.entity.QModelResultMetricEntity.modelResultMetricEntity; import com.kamco.cd.kamcoback.model.dto.ModelMgmtDto; import com.kamco.cd.kamcoback.postgres.QuerydslOrderUtil; @@ -10,8 +11,10 @@ import com.querydsl.core.types.Expression; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -79,8 +82,15 @@ public class ModelMgmtRepositoryImpl extends QuerydslRepositorySupport "to_char({0}, 'YYYY-MM-DD')", modelMgmtEntity.createCompleteDttm), Expressions.stringTemplate( "to_char({0}, 'YYYY-MM-DD')", modelMgmtEntity.recentUseDttm), + roundNumericToPercent(modelResultMetricEntity.f1Score), + roundNumericToPercent(modelResultMetricEntity.precision), + roundNumericToPercent(modelResultMetricEntity.recall), + roundNumericToPercent(modelResultMetricEntity.loss), + roundNumericToPercent(modelResultMetricEntity.iou), modelMgmtEntity.deleted)) .from(modelMgmtEntity) + .innerJoin(modelResultMetricEntity) + .on(modelMgmtEntity.modelUid.longValue().eq(modelResultMetricEntity.modelUid)) .where( eventEndedAtBetween(startDate, endDate, property), searchModelVersion(modelType, searchVal)) @@ -138,4 +148,8 @@ public class ModelMgmtRepositoryImpl extends QuerydslRepositorySupport return builder; } + + private Expression roundNumericToPercent(NumberPath ratio) { + return Expressions.numberTemplate(BigDecimal.class, "function('round', {0} * 100, 2)", ratio); + } }