Spaces:
Sleeping
Sleeping
Download src/models/task.model.ts from sardarbipul/test: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/models/task.model.ts
- Command line
-
hf download hf://spaces/sardarbipul/test/src/models/task.model.ts
-
curl -L -o task.model.ts https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/models/task.model.ts
1.4 kB
| import { ITask, TaskStatus } from '../types/task.types'; | |
| export class TaskModel implements ITask { | |
| public taskId: string; | |
| public startRow: number; | |
| public endRow: number; | |
| public startOffset?: number; | |
| public endOffset?: number; | |
| public workerId: string | null; | |
| public status: TaskStatus; | |
| public retries: number; | |
| public progress: number; | |
| public rowsProcessed?: number; | |
| public leaseUntil: string | null; | |
| public createdAt: string; | |
| public updatedAt: string; | |
| public completedAt: string | null; | |
| public errorMessage?: string | null; | |
| constructor(data: Partial<ITask> & { taskId: string; startRow: number; endRow: number }) { | |
| const now = new Date().toISOString(); | |
| this.taskId = data.taskId; | |
| this.startRow = data.startRow; | |
| this.endRow = data.endRow; | |
| this.startOffset = data.startOffset; | |
| this.endOffset = data.endOffset; | |
| this.workerId = data.workerId || null; | |
| this.status = data.status || 'pending'; | |
| this.retries = data.retries || 0; | |
| this.progress = data.progress || 0; | |
| this.rowsProcessed = data.rowsProcessed || 0; | |
| this.leaseUntil = data.leaseUntil || null; | |
| this.createdAt = data.createdAt || now; | |
| this.updatedAt = data.updatedAt || now; | |
| this.completedAt = data.completedAt || null; | |
| this.errorMessage = data.errorMessage || null; | |
| } | |
| public static toJSON(task: ITask): ITask { | |
| return { ...task }; | |
| } | |
| } | |