init record notion

This commit is contained in:
Julien Calixte
2023-04-09 22:56:09 +02:00
parent 7e8cdd4b78
commit fb02f28465
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import type { Recordable } from '../interfaces/recordable'
export class TaskRecord implements Recordable {
public start: Date = new Date()
public end: Date | undefined = undefined
public stepRecords: Record<string, { minutes: number }> = {}
public constructor(
public readonly id: string,
public readonly taskId: string
) {}
public get duration(): number | null {
if (!this.end) {
return null
}
const durationMilliseconds = this.end.getTime() - this.start.getTime()
return Math.round(durationMilliseconds / (1000 * 60))
}
}