feat(red bin and green bin): status is ko if the duration is off by 10% the estimation (min 1min)
This commit is contained in:
@@ -4,6 +4,7 @@ import { formatDiffInMinutes } from '@/shared/format-date'
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { computed, onUnmounted, ref } from 'vue'
|
||||
import { useTaskRecordStore } from '../stores/useTaskRecordStore'
|
||||
import { is10PercentOffThanEstimation } from '@/modules/record/services/compare-with-estimation'
|
||||
|
||||
const props = defineProps<{
|
||||
taskId: string
|
||||
@@ -52,12 +53,15 @@ const duration = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const isGreaterThanEstimation = computed(() => {
|
||||
const isOffEstimation = computed(() => {
|
||||
if (!step.value || !stepRecord.value || !duration.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
return duration.value > step.value.estimation
|
||||
return is10PercentOffThanEstimation({
|
||||
estimation: step.value.estimation,
|
||||
duration: duration.value
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -80,9 +84,9 @@ const isGreaterThanEstimation = computed(() => {
|
||||
</div>
|
||||
</td>
|
||||
<td class="status">
|
||||
<span v-if="stepRecord?.end && !isGreaterThanEstimation">✅</span>
|
||||
<span v-else-if="isGreaterThanEstimation">❓</span>
|
||||
<span v-else>⌛</span>
|
||||
<span v-if="!stepRecord?.end">⌛</span>
|
||||
<span v-else-if="isOffEstimation">❓</span>
|
||||
<span v-else>✅</span>
|
||||
</td>
|
||||
<td class="step-title">
|
||||
{{ step.title }}
|
||||
|
||||
19
src/modules/record/services/compare-with-estimation.test.ts
Normal file
19
src/modules/record/services/compare-with-estimation.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { is10PercentOffThanEstimation } from '@/modules/record/services/compare-with-estimation'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
describe('compareWithEstimation', () => {
|
||||
it('should tells if the estimation is off by 10% or more', () => {
|
||||
expect(is10PercentOffThanEstimation({ estimation: 10, duration: 9 })).toBe(
|
||||
false
|
||||
)
|
||||
expect(is10PercentOffThanEstimation({ estimation: 5, duration: 4 })).toBe(
|
||||
false
|
||||
)
|
||||
expect(is10PercentOffThanEstimation({ estimation: 10, duration: 5 })).toBe(
|
||||
true
|
||||
)
|
||||
expect(is10PercentOffThanEstimation({ estimation: 10, duration: 8 })).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
9
src/modules/record/services/compare-with-estimation.ts
Normal file
9
src/modules/record/services/compare-with-estimation.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const is10PercentOffThanEstimation = ({
|
||||
estimation,
|
||||
duration
|
||||
}: {
|
||||
estimation: number
|
||||
duration: number
|
||||
}) => {
|
||||
return Math.abs(duration - estimation) > Math.max(estimation * 0.1, 1)
|
||||
}
|
||||
Reference in New Issue
Block a user