fix: count skipped stages in parsing progress
parent
60028cbe0e
commit
d3055ae068
|
|
@ -0,0 +1,28 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const source = readFileSync(join(here, 'knowledge-processing-timeline.vue'), 'utf8')
|
||||
|
||||
test('counts skipped stages when determining the current stage', () => {
|
||||
const currentStageIndex = source.slice(
|
||||
source.indexOf('const currentStageIndex'),
|
||||
source.indexOf('function formatDuration'),
|
||||
)
|
||||
|
||||
assert.match(currentStageIndex, /status === 'done' \|\| s\.status === 'skipped'/)
|
||||
assert.match(currentStageIndex, /Math\.min\(traversed \+ 1, stages\.value\.length\)/)
|
||||
})
|
||||
|
||||
test('counts skipped stages in the completed stage total', () => {
|
||||
const stagesStatDisplay = source.slice(
|
||||
source.indexOf('const stagesStatDisplay'),
|
||||
source.indexOf('const postprocessTaskStats'),
|
||||
)
|
||||
|
||||
assert.match(stagesStatDisplay, /status === 'done' \|\| s\.status === 'skipped'/)
|
||||
assert.match(stagesStatDisplay, /value: `\$\{completedCount\}\/\$\{total\}`/)
|
||||
})
|
||||
|
|
@ -167,8 +167,10 @@ const currentStageLabel = computed(() => {
|
|||
const currentStageIndex = computed(() => {
|
||||
const idx = stages.value.findIndex((s) => s.status === 'running' || s.status === 'failed')
|
||||
if (idx >= 0) return idx + 1
|
||||
const done = stages.value.filter((s) => s.status === 'done').length
|
||||
return Math.min(done + 1, stages.value.length)
|
||||
const traversed = stages.value.filter(
|
||||
(s) => s.status === 'done' || s.status === 'skipped',
|
||||
).length
|
||||
return Math.min(traversed + 1, stages.value.length)
|
||||
})
|
||||
|
||||
function formatDuration(ms?: number): string {
|
||||
|
|
@ -1182,7 +1184,9 @@ const showLastError = computed(() =>
|
|||
|
||||
const stagesStatDisplay = computed(() => {
|
||||
const total = stages.value.length
|
||||
const doneCount = stages.value.filter((s) => s.status === 'done').length
|
||||
const completedCount = stages.value.filter(
|
||||
(s) => s.status === 'done' || s.status === 'skipped',
|
||||
).length
|
||||
const inProgress = stages.value.some(
|
||||
(s) => s.status === 'running' || s.status === 'failed' || s.status === 'pending',
|
||||
)
|
||||
|
|
@ -1194,7 +1198,7 @@ const stagesStatDisplay = computed(() => {
|
|||
}
|
||||
return {
|
||||
label: t('knowledgeStages.head.stagesDone'),
|
||||
value: `${doneCount}/${total}`,
|
||||
value: `${completedCount}/${total}`,
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue