web/queue: replace pipelineResults array with object

This commit is contained in:
jj
2025-05-23 17:44:47 +00:00
parent 17bcfa3a03
commit 892c055d6a
7 changed files with 38 additions and 28 deletions

View File

@@ -96,7 +96,8 @@
// if only fetch workers are running, then we should
// show the sum of all running & completed fetch workers
if (running.size === 1 && running.has("fetch")) {
totalSize += info.pipelineResults.reduce((s, p) => s + (p?.size ?? 0), 0);
totalSize += Object.values(info.pipelineResults)
.reduce((s, p) => s + (p?.size ?? 0), 0);
}
const runningText = [...running].map(task => $t(`queue.state.running.${task}`)).join(", ");
@@ -107,7 +108,7 @@
}
const firstUnstarted = info.pipeline.find(w => {
if (info.completedWorkers.has(w.workerId))
if (info.pipelineResults[w.workerId])
return false;
const task = currentTasks[w.workerId];
@@ -134,7 +135,7 @@
};
const getWorkerProgress = (item: CobaltQueueItem, workerId: UUID): number | undefined => {
if (item.state === 'running' && item.completedWorkers.has(workerId)) {
if (item.state === 'running' && item.pipelineResults[workerId]) {
return 100;
}
@@ -187,7 +188,7 @@
<ProgressBar
percentage={getWorkerProgress(info, task.workerId) || 0}
workerId={task.workerId}
completedWorkers={info.completedWorkers}
pipelineResults={info.pipelineResults}
/>
{/each}
</div>

View File

@@ -1,14 +1,14 @@
<script lang="ts">
import Skeleton from "$components/misc/Skeleton.svelte";
import type { UUID } from "$lib/types/queue";
import type { CobaltQueueItemRunning, UUID } from "$lib/types/queue";
type Props = {
percentage?: number;
workerId: UUID;
completedWorkers: Set<string>;
pipelineResults: CobaltQueueItemRunning['pipelineResults'];
}
let { percentage = 0, workerId, completedWorkers }: Props = $props();
let { percentage = 0, workerId, pipelineResults }: Props = $props();
</script>
<div class="file-progress">
@@ -17,7 +17,7 @@
class="progress"
style="width: {Math.min(100, percentage)}%"
></div>
{:else if completedWorkers.has(workerId)}
{:else if pipelineResults[workerId]}
<div
class="progress"
style="width: 100%"