mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix: count perpetual runs past the first queue page in the deploy prompt
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
72233f51c4
commit
e1daa39655
@@ -16,7 +16,6 @@
|
||||
|
||||
const runsText = $derived.by(() => {
|
||||
if (!runs) return ''
|
||||
if (runs.truncated) return `At least ${runs.count} runs of this script are`
|
||||
return runs.count === 1 ? '1 run of this script is' : `${runs.count} runs of this script are`
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,27 +1,37 @@
|
||||
import { JobService, ScriptService } from '$lib/gen'
|
||||
import { JobService, ScriptService, type QueuedJob } from '$lib/gen'
|
||||
import { computeDiff } from '$lib/components/schema/schemaUtils.svelte'
|
||||
|
||||
const RUNS_PAGE_SIZE = 100
|
||||
const QUEUE_PAGE_SIZE = 1000
|
||||
|
||||
export type PerpetualRunsAtPath = {
|
||||
count: number
|
||||
/** More runs than one page holds are queued at the path, so `count` is a lower bound. */
|
||||
truncated: boolean
|
||||
/** Arguments the deployed schema removes, retypes or newly requires, compared with the runs' versions. */
|
||||
mismatchedArgs: string[]
|
||||
}
|
||||
|
||||
// Every page: the deploy switches every perpetual run at the path, so one past the first page
|
||||
// still needs the prompt and its version's arguments compared.
|
||||
async function listQueuedAtPath(workspace: string, path: string): Promise<QueuedJob[]> {
|
||||
const jobs = new Map<string, QueuedJob>()
|
||||
for (let page = 1; ; page++) {
|
||||
const batch = await JobService.listQueue({
|
||||
workspace,
|
||||
scriptPathExact: path,
|
||||
jobKinds: 'script',
|
||||
perPage: QUEUE_PAGE_SIZE,
|
||||
page
|
||||
})
|
||||
for (const job of batch) jobs.set(job.id, job)
|
||||
if (batch.length < QUEUE_PAGE_SIZE) return [...jobs.values()]
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadPerpetualRunsAtPath(
|
||||
workspace: string,
|
||||
path: string,
|
||||
schema: { [key: string]: any } | undefined
|
||||
): Promise<PerpetualRunsAtPath | undefined> {
|
||||
const queued = await JobService.listQueue({
|
||||
workspace,
|
||||
scriptPathExact: path,
|
||||
jobKinds: 'script',
|
||||
perPage: RUNS_PAGE_SIZE
|
||||
})
|
||||
const queued = await listQueuedAtPath(workspace, path)
|
||||
// Only what the backend restarts: never a flow step, and only a run of a perpetual version.
|
||||
const candidates = queued.filter((job) => !job.is_flow_step && job.script_hash)
|
||||
const hashes = [...new Set(candidates.map((job) => job.script_hash!))]
|
||||
@@ -56,7 +66,6 @@ export async function loadPerpetualRunsAtPath(
|
||||
|
||||
return {
|
||||
count: runs.length,
|
||||
truncated: queued.length === RUNS_PAGE_SIZE,
|
||||
mismatchedArgs: [...mismatchedArgs]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user