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

fix: schedule latest version #1263

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pkg/repository/prisma/dbsqlc/tickers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,28 @@ RETURNING cronSchedules.*, active_cron_schedules."workflowVersionId", active_cro
-- to a ticker, or finds workflows that were assigned to a ticker that is no longer active
WITH not_run_scheduled_workflows AS (
SELECT
latestVersions."version",
scheduledWorkflow."id",
versions."id" AS "workflowVersionId",
latestVersions."id" AS "workflowVersionId",
workflow."tenantId" AS "tenantId",
scheduledWorkflow."additionalMetadata" AS "additionalMetadata"
FROM
"WorkflowTriggerScheduledRef" as scheduledWorkflow
"WorkflowTriggerScheduledRef" AS scheduledWorkflow
JOIN
"WorkflowVersion" AS versions ON versions."id" = scheduledWorkflow."parentId"
JOIN
"WorkflowVersion" as versions ON versions."id" = scheduledWorkflow."parentId"
"Workflow" AS workflow ON workflow."id" = versions."workflowId"
JOIN
"Workflow" as workflow ON workflow."id" = versions."workflowId"
(
-- Subquery to get the latest version per workflow
SELECT DISTINCT ON ("workflowId")
"id", "workflowId", "version"
FROM "WorkflowVersion"
WHERE "deletedAt" IS NULL
ORDER BY "workflowId", "version" DESC
) AS latestVersions ON latestVersions."workflowId" = workflow."id"
LEFT JOIN
"WorkflowRunTriggeredBy" as runTriggeredBy ON runTriggeredBy."scheduledId" = scheduledWorkflow."id"
"WorkflowRunTriggeredBy" AS runTriggeredBy ON runTriggeredBy."scheduledId" = scheduledWorkflow."id"
WHERE
"triggerAt" <= NOW() + INTERVAL '5 seconds'
AND runTriggeredBy IS NULL
Expand Down
22 changes: 16 additions & 6 deletions pkg/repository/prisma/dbsqlc/tickers.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading