fix record resume total duration
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user