add problems to step records
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { toISODate, type ISODate } from '@/shared/types/date'
|
||||
import type { Recordable } from '../interfaces/recordable'
|
||||
import type { StepRecordable } from '../interfaces/step-recordable'
|
||||
|
||||
export class TaskRecord implements Recordable {
|
||||
public start: ISODate = toISODate(new Date())
|
||||
public end: ISODate | undefined = undefined
|
||||
public stepRecords: Record<string, { start: ISODate; end?: ISODate }> = {}
|
||||
public stepRecords: Record<string, StepRecordable> = {}
|
||||
|
||||
public constructor(
|
||||
public readonly id: string,
|
||||
@@ -21,4 +22,14 @@ export class TaskRecord implements Recordable {
|
||||
|
||||
return Math.round(durationMilliseconds / (1000 * 60))
|
||||
}
|
||||
|
||||
public static fromRecordable(recordable: Recordable) {
|
||||
const taskRecord = new TaskRecord(recordable.id, recordable.taskId)
|
||||
|
||||
taskRecord.stepRecords = recordable.stepRecords
|
||||
taskRecord.start = recordable.start
|
||||
taskRecord.end = recordable.end
|
||||
|
||||
return taskRecord
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user