import {
  Entity,
  Column,
  PrimaryColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity('conversations')
export class ConversationORM {
  @PrimaryColumn('uuid')
  id: string;

  @Column({ name: 'user_id', nullable: true })
  userId: string;

  @Column({ length: 20, default: 'ACTIVE' })
  status: string;

  @Column({ length: 255, nullable: true })
  title: string;

  @Column('text', { nullable: true })
  summary: string;

  @Column({ length: 50, nullable: true })
  category: string;

  @Column({ name: 'message_count', default: 0 })
  messageCount: number;

  @Column({ name: 'user_message_count', default: 0 })
  userMessageCount: number;

  @Column({ name: 'assistant_message_count', default: 0 })
  assistantMessageCount: number;

  @Column({ name: 'total_input_tokens', default: 0 })
  totalInputTokens: number;

  @Column({ name: 'total_output_tokens', default: 0 })
  totalOutputTokens: number;

  @Column({ type: 'smallint', nullable: true })
  rating: number;

  @Column('text', { nullable: true })
  feedback: string;

  @Column({ name: 'has_converted', default: false })
  hasConverted: boolean;

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt: Date;

  @Column({ name: 'ended_at', nullable: true })
  endedAt: Date;
}
