Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Check for skipped state in task run table to fix endless duration #1134

Merged
merged 11 commits into from
Dec 7, 2021
Merged
14 changes: 5 additions & 9 deletions src/pages/FlowRun/TaskRunTable-Tile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import moment from 'moment-timezone'
import DurationSpan from '@/components/DurationSpan'
import ResumeButton from '@/components/ResumeButton'
import { formatTime } from '@/mixins/formatTimeMixin'
import { FINISHED_STATES, STATE_NAMES } from '@/utils/states'
import { STATE_NAMES } from '@/utils/states'
import { calculateDuration } from '@/utils/states'

export default {
components: {
CardTitle,
Expand Down Expand Up @@ -98,9 +100,7 @@ export default {
return true
}
},
isFinished(state) {
return FINISHED_STATES.includes(state)
}
calculateDuration
},
apollo: {
flowRun: {
Expand Down Expand Up @@ -279,11 +279,7 @@ export default {
v-if="item.start_time"
:start-time="item.start_time"
:end-time="
item.end_time
? item.end_time
: isFinished(item.state)
? item.start_time
: null
calculateDuration(item.start_time, item.end_time, item.state)
"
/>
<span v-else>...</span>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/Task/TaskRunTable-Tile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CardTitle from '@/components/Card-Title'
import { roundedOneAgo } from '@/utils/dateTime'
import DurationSpan from '@/components/DurationSpan'
import { formatTime } from '@/mixins/formatTimeMixin'
import { calculateDuration } from '@/utils/states'

export default {
components: {
Expand Down Expand Up @@ -71,7 +72,9 @@ export default {
return `%${this.searchTerm}%`
}
},
methods: {},
methods: {
calculateDuration
},
apollo: {
task: {
query: require('@/graphql/Task/table-task-runs.gql'),
Expand Down Expand Up @@ -200,7 +203,9 @@ export default {
<DurationSpan
v-if="item.start_time"
:start-time="item.start_time"
:end-time="item.end_time"
:end-time="
calculateDuration(item.start_time, item.end_time, item.state)
"
/>
<span v-else>...</span>
</template>
Expand Down
13 changes: 10 additions & 3 deletions src/pages/TaskRun/Details-Tile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import CardTitle from '@/components/Card-Title'
import DurationSpan from '@/components/DurationSpan'
import { formatTime } from '@/mixins/formatTimeMixin'

import { calculateDuration } from '@/utils/states'
export default {
filters: {
typeClass: val => val.split('.').pop()
Expand Down Expand Up @@ -50,7 +50,8 @@ export default {
this.copiedText = {}
this.copiedText[text] = false
}, 1000)
}
},
calculateDuration
}
}
</script>
Expand Down Expand Up @@ -192,7 +193,13 @@ export default {
<DurationSpan
v-if="taskRun.start_time"
:start-time="taskRun.start_time"
:end-time="taskRun.end_time"
:end-time="
calculateDuration(
taskRun.start_time,
taskRun.end_time,
taskRun.state
)
"
/>
<span v-else>
<v-skeleton-loader type="text"></v-skeleton-loader>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/TaskRun/MappedTaskRuns-Tile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import CardTitle from '@/components/Card-Title'
import DurationSpan from '@/components/DurationSpan'
import { formatTime } from '@/mixins/formatTimeMixin'
import { calculateDuration } from '@/utils/states'

export default {
components: {
Expand Down Expand Up @@ -75,7 +76,9 @@ export default {
return `%${this.searchTerm}%`
}
},
methods: {},
methods: {
calculateDuration
},
apollo: {
taskRuns: {
query: require('@/graphql/TaskRun/table-mapped-task-runs.gql'),
Expand Down Expand Up @@ -274,7 +277,9 @@ export default {
<DurationSpan
v-if="item.start_time"
:start-time="item.start_time"
:end-time="item.end_time"
:end-time="
calculateDuration(item.start_time, item.end_time, item.state)
"
/>
<span v-else>...</span>
</template>
Expand Down
12 changes: 12 additions & 0 deletions src/utils/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ export const FINISHED_STATES = [
'Skipped'
]

export function calculateDuration(startTime, endTime, state) {
if (endTime) {
return endTime
}

if (FINISHED_STATES.includes(state)) {
return startTime
}

return null
}

export default function(state) {
return STATE_COLORS[state]
}