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<String, Object> 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();
  }
}
