import { Document, Types } from 'mongoose';
import { IPaginateModel } from '@/shared/interfaces/model.interface';
import { AuditFields } from '@/shared/types/common';

export interface IUnitJobError {
  row: number;
  message: string;
}

export interface IUnitJobBase {
  project: Types.ObjectId;
  jobId: string;
  status: 'pending' | 'processing' | 'completed' | 'failed';
  progress: number;
  totalUnits: number;
  processedUnits: number;
  successfulUnits: number;
  failedUnits: number;
  errorRecords: IUnitJobError[];
  filePath: string;
  fileName: string;
}

export interface IUnitJob extends IUnitJobBase, AuditFields {}

export interface IUnitJobDoc extends IUnitJob, Document {}

export interface IUnitJobModel extends IPaginateModel<IUnitJobDoc> {}

export type NewCreatedUnitJob = IUnitJobBase &
  Partial<Pick<AuditFields, 'createdBy' | 'updatedBy'>>;

export type UpdateUnitJobBody = Partial<IUnitJob>;

export interface IUnitJobFilter {
  project?: Types.ObjectId | string;
  search?: string;
  status?: string;
  createdBy?: Types.ObjectId | string;
  jobId?: string;
}
