import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { AiInterviewSchedules } from '../../ai_interview_schedules/entities/ai_interview_schedules.entity';

@Entity('user_ai_interviews')
export class UserAiInterviews {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'int' })
  user_id: number;

  @Column({ type: 'int' })
  job_post_id: number;

  @Column({ type: 'int', nullable: true })
  application_id: number;

  @Column({ type: 'int', nullable: true })
  schedule_id: number;

  @Column({
    type: 'enum',
    enum: ['instant', 'scheduled'],
  })
  interview_mode: 'instant' | 'scheduled';

  @Column({ type: 'int' })
  total_questions: number;

  @Column({
    type: 'enum',
    enum: ['pending', 'in_progress', 'completed'],
    default: 'pending',
  })
  status: 'pending' | 'in_progress' | 'completed';

  @Column({ type: 'datetime', nullable: true })
  started_at: Date;

  @Column({ type: 'datetime', nullable: true })
  completed_at: Date;

  @Column({ type: 'decimal', precision: 6, scale: 2, nullable: true })
  score: number;

  @Column({ type: 'json', nullable: true })
  ai_session_metadata: any;

  @Column({ type: 'json', nullable: true })
  ai_feedback_json: any;

  @Column({ type: 'json', nullable: true })
  skill_scores: any;

  @Column({ type: 'json', nullable: true })
  submission_meta: any;

  @Column({ type: 'json', nullable: true })
  weak_topics: any;

  @Column({ type: 'json', nullable: true })
  strong_topics: any;

  @CreateDateColumn()
  created_at: Date;
}
