fix flowstatusviewer and updating to in_progress much sooner
This commit is contained in:
@@ -283,10 +283,11 @@ pub async fn update_flow_status_in_progress(
|
||||
let step = get_step_of_flow_status(db, flow).await?;
|
||||
sqlx::query(&format!(
|
||||
"UPDATE queue
|
||||
SET flow_status = jsonb_set(flow_status, '{{modules, {step}, job}}', $1)
|
||||
WHERE id = $2 AND workspace_id = $3",
|
||||
SET flow_status = jsonb_set(jsonb_set(flow_status, '{{modules, {step}, job}}', $1), '{{modules, {step}, type}}', $2)
|
||||
WHERE id = $3 AND workspace_id = $4",
|
||||
))
|
||||
.bind(json!(job_in_progress.to_string()))
|
||||
.bind(json!("InProgress"))
|
||||
.bind(flow)
|
||||
.bind(w_id)
|
||||
.execute(db)
|
||||
|
||||
@@ -5,19 +5,18 @@
|
||||
import Icon from 'svelte-awesome'
|
||||
import { check } from 'svelte-awesome/icons'
|
||||
|
||||
import { CompletedJob, FlowStatusModule, JobService, QueuedJob } from '$lib/gen'
|
||||
import { CompletedJob, FlowStatusModule, Job, JobService, QueuedJob } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import FlowJobResult from './FlowJobResult.svelte'
|
||||
import JobStatus from './JobStatus.svelte'
|
||||
|
||||
export let job: QueuedJob | CompletedJob
|
||||
export let jobs: (CompletedJob | CompletedJob[] | undefined)[] = []
|
||||
export let jobs: (Job | Job[] | undefined)[] = []
|
||||
|
||||
let lastJobid: string | undefined
|
||||
|
||||
let forloop_selected = ''
|
||||
|
||||
let logs: { [key: number]: string } = {}
|
||||
let pres: { [key: number]: HTMLElement } = {}
|
||||
|
||||
async function loadResults() {
|
||||
@@ -27,13 +26,12 @@
|
||||
let i = mods?.findIndex((x) => x.type == FlowStatusModule.type.IN_PROGRESS)
|
||||
if (i != -1) {
|
||||
let last = mods[i]
|
||||
if (last?.type == FlowStatusModule.type.IN_PROGRESS) {
|
||||
logs[i] =
|
||||
(await JobService.getJob({ workspace: $workspaceStore ?? '', id: last.job ?? '' }))
|
||||
.logs ?? ''
|
||||
logs = logs
|
||||
pres[i].scroll({ top: pres[i]?.scrollHeight, behavior: 'smooth' })
|
||||
}
|
||||
jobs[i] = await JobService.getJob({
|
||||
workspace: $workspaceStore ?? '',
|
||||
id: last.job ?? ''
|
||||
})
|
||||
jobs = jobs
|
||||
pres[i].scroll({ top: pres[i]?.scrollHeight, behavior: 'smooth' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +61,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
function toJob(x: any): Job {
|
||||
return x as Job
|
||||
}
|
||||
|
||||
function toCompletedJob(x: any): CompletedJob {
|
||||
return x as CompletedJob
|
||||
}
|
||||
@@ -99,6 +101,7 @@
|
||||
{#each job?.raw_flow?.modules ?? [] as mod, i}
|
||||
<li class="w-full">
|
||||
<div class="relative pb-8 w-full">
|
||||
{job.flow_status?.modules[i].type}
|
||||
{#if i < (job?.raw_flow?.modules ?? []).length - 1}
|
||||
<span
|
||||
class="absolute top-4 left-4 -ml-px h-full w-0.5 bg-gray-200"
|
||||
@@ -199,18 +202,18 @@
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
{:else if toJob(jobs[i]).type == 'CompletedJob'}
|
||||
<FlowJobResult job={toCompletedJob(jobs[i])} />
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="mx-20">
|
||||
<pre
|
||||
bind:this={pres[i]}
|
||||
class="break-all p-4 relative h-full mx-2 bg-gray-50 text-xs max-h-40 overflow-y-auto border">{logs[
|
||||
i
|
||||
] ?? ''}
|
||||
{:else if jobs[i]}
|
||||
<div class="mx-20">
|
||||
<pre
|
||||
bind:this={pres[i]}
|
||||
class="break-all p-4 relative h-full mx-2 bg-gray-50 text-xs max-h-40 overflow-y-auto border">{toJob(
|
||||
jobs[i]
|
||||
).logs ?? ''}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user