fix record resume total duration

This commit is contained in:
Julien Calixte
2023-07-29 13:27:22 +02:00
parent a1c6395d12
commit 6bca3957af
2 changed files with 7 additions and 10 deletions

View File

@@ -8,7 +8,8 @@ const props = defineProps<{
totalEstimation: number
}>()
const { duration } = useTaskRecordMetadata(props.record)
const record = computed(() => props.record)
const { duration } = useTaskRecordMetadata(record)
const isSuperiorToEstimation = computed(() => {
if (!duration.value) {
@@ -32,8 +33,3 @@ const isSuperiorToEstimation = computed(() => {
</p>
</div>
</template>
<style scoped lang="scss">
.record-resume {
}
</style>

View File

@@ -1,19 +1,20 @@
import type { Recordable } from '@/modules/record/interfaces/recordable'
import { formatDiffInMinutes } from '@/shared/format-date'
import { computed, isRef, type Ref } from 'vue'
import { toValue } from '@vueuse/core'
import { computed, type ComputedRef } from 'vue'
export const useTaskRecordMetadata = (
record: Recordable | Ref<Recordable | null>
record: ComputedRef<Recordable | null>
) => {
const taskDurations = computed(() => {
const recordValue = isRef(record) ? record.value : record
const recordValue = toValue(record)
if (!recordValue?.end) {
return []
}
const finishedTaskDurations = Object.values(recordValue.stepRecords)
.filter((record) => !!record.end)
.filter((r) => !!r.end)
.map((record) => formatDiffInMinutes(record.start, record.end!))
return finishedTaskDurations