import { BaseModel } from 'src/core/modules/data/model/base.model';
import { Entity, Column } from 'typeorm';
import { REPORT_HISTORY_STATUS } from '../constant';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ExportReportHistoryEntity } from '../entities/export-report-history.entity';

@Entity(TABLE_NAME.EXPORT_REPORT_HISTORY)
export class ExportReportHistoryModel
  extends BaseModel<ExportReportHistoryEntity>
  implements ExportReportHistoryEntity
{
  @Column('varchar')
  group_name: string;

  @Column('varchar')
  unique_name: string;

  @Column('varchar')
  label: string;

  @Column('varchar')
  file_name: string;

  @Column('varchar', { nullable: true })
  file_url: string;

  @Column('int', { default: 0 })
  total_data: number;

  @Column('int', { default: 0 })
  processing_data: number;

  @Column('enum', { nullable: true, enum: REPORT_HISTORY_STATUS })
  status: REPORT_HISTORY_STATUS;

  @Column('int', { default: 0 })
  last_process_offset: number;

  @Column('int', { default: 0 })
  last_process_limit: number;

  @Column('int', { default: 0 })
  total_resume: number;

  @Column('bigint', { nullable: true })
  last_resume_created_at: number;

  @Column('varchar', { nullable: true })
  query_export: string;

  @Column({ type: 'bigint', nullable: true })
  canceled_at: number;
}
