import { Transform, Type } from 'class-transformer' import { BaseModel } from '../../base.model' import { parseDate } from '../../../utils/date' import { Patient } from '../../patient.model' import { CompetitionHistory } from './history' export class CompetitionCompetitor extends BaseModel { id: string competition_id: string patient_id: string patient_name: string patient_photo_url: string score: number position: number is_subscriber: boolean @Transform(value => parseDate(value), { toClassOnly: true }) created_at: Date @Transform(value => parseDate(value), { toClassOnly: true }) updated_at: Date @Type(() => CompetitionHistory) history: CompetitionHistory[] @Type(() => Patient) patient: Patient get lastHistory(): CompetitionHistory { return this.history?.[this.history?.length - 1] } }