package org.raddatz.familienarchiv.ocr;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;

import java.time.Instant;
import java.util.UUID;

@Entity
@Table(name = "ocr_training_runs")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OcrTrainingRun {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private UUID id;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private TrainingStatus status;

    @Column(name = "block_count", nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private int blockCount;

    @Column(name = "document_count", nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private int documentCount;

    @Column(name = "model_name", nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private String modelName;

    @Column(name = "cer")
    private Double cer;

    @Column(name = "loss")
    private Double loss;

    @Column(name = "accuracy")
    private Double accuracy;

    @Column(name = "epochs")
    private Integer epochs;

    @Column(name = "error_message")
    private String errorMessage;

    @Column(name = "triggered_by")
    private UUID triggeredBy;

    @Column(name = "person_id")
    private UUID personId;

    @CreationTimestamp
    @Column(name = "created_at", nullable = false, updatable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private Instant createdAt;

    @Column(name = "completed_at")
    private Instant completedAt;
}
