♻️ (record) time range instead of step recordable

This commit is contained in:
Julien Calixte
2023-04-16 10:16:42 +02:00
parent 81cfab485e
commit d5c616e22b
4 changed files with 7 additions and 11 deletions

View File

@@ -1,14 +1,10 @@
import type { ISODate } from '@/shared/types/date' import type { ISODate } from '@/shared/types/date'
import type { StepRecordable } from './step-recordable' import type { TimeRange } from './time-range'
export interface Recordable { export interface Recordable {
taskId: string taskId: string
/**
* @deprecated
* TODO: Compute this data from step records
*/
start: ISODate start: ISODate
end?: ISODate end?: ISODate
stepRecords: Record<string, StepRecordable> stepRecords: Record<string, TimeRange>
notes: string notes: string
} }

View File

@@ -1,6 +1,6 @@
import type { ISODate } from '@/shared/types/date' import type { ISODate } from '@/shared/types/date'
export interface StepRecordable { export interface TimeRange {
start: ISODate start: ISODate
end?: ISODate end?: ISODate
} }

View File

@@ -1,11 +1,11 @@
import { toISODate, type ISODate } from '@/shared/types/date' import { toISODate, type ISODate } from '@/shared/types/date'
import type { Recordable } from '../interfaces/recordable' import type { Recordable } from '../interfaces/recordable'
import type { StepRecordable } from '../interfaces/step-recordable' import type { TimeRange } from '../interfaces/time-range'
export class TaskRecord implements Recordable { export class TaskRecord implements Recordable {
public start: ISODate = toISODate(new Date()) public start: ISODate = toISODate(new Date())
public end: ISODate | undefined = undefined public end: ISODate | undefined = undefined
public stepRecords: Record<string, StepRecordable> = {} public stepRecords: Record<string, TimeRange> = {}
public notes = '' public notes = ''
public constructor(public readonly taskId: string) {} public constructor(public readonly taskId: string) {}

View File

@@ -1,7 +1,7 @@
import { toISODate, type ISODate } from '@/shared/types/date' import { toISODate, type ISODate } from '@/shared/types/date'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import type { Recordable } from '../interfaces/recordable' import type { Recordable } from '../interfaces/recordable'
import type { StepRecordable } from '../interfaces/step-recordable' import type { TimeRange } from '../interfaces/time-range'
import { TaskRecord } from '../models/task-record' import { TaskRecord } from '../models/task-record'
export interface TaskRecordStoreState { export interface TaskRecordStoreState {
@@ -133,7 +133,7 @@ export const useTaskRecordStore = defineStore('task-record-store', {
return (taskId: string): Recordable | null => this.records[taskId] ?? null return (taskId: string): Recordable | null => this.records[taskId] ?? null
}, },
getStepRecord() { getStepRecord() {
return (taskId: string, stepId: string): StepRecordable | null => return (taskId: string, stepId: string): TimeRange | null =>
this.records[taskId]?.stepRecords[stepId] ?? null this.records[taskId]?.stepRecords[stepId] ?? null
}, },
getRecordNotes() { getRecordNotes() {