Skip to content

Commit

Permalink
feat: toggle crons to enabled/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
abelanger5 committed Apr 24, 2024
1 parent d29e90b commit 519167e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions internal/repository/prisma/dbsqlc/models.go

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

3 changes: 2 additions & 1 deletion internal/repository/prisma/dbsqlc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ CREATE TABLE "WorkflowTriggerCronRef" (
"parentId" UUID NOT NULL,
"cron" TEXT NOT NULL,
"tickerId" UUID,
"input" JSONB
"input" JSONB,
"enabled" BOOLEAN NOT NULL DEFAULT true
);

-- CreateTable
Expand Down
5 changes: 3 additions & 2 deletions internal/repository/prisma/dbsqlc/tickers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ active_cron_schedules AS (
JOIN
latest_workflow_versions l ON versions."workflowId" = l."workflowId" AND versions."order" = l.max_order
WHERE
"tickerId" IS NULL
"enabled" = TRUE AND
("tickerId" IS NULL
OR NOT EXISTS (
SELECT 1 FROM "Ticker" WHERE "id" = cronSchedule."tickerId" AND "isActive" = true AND "lastHeartbeatAt" >= NOW() - INTERVAL '10 seconds'
)
OR "tickerId" = @tickerId::uuid
OR "tickerId" = @tickerId::uuid)
FOR UPDATE SKIP LOCKED
)
UPDATE
Expand Down
9 changes: 6 additions & 3 deletions internal/repository/prisma/dbsqlc/tickers.sql.go

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

3 changes: 2 additions & 1 deletion internal/repository/prisma/dbsqlc/workflows.sql.go

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

2 changes: 2 additions & 0 deletions prisma/migrations/20240424091046_v0_21_9/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "WorkflowTriggerCronRef" ADD COLUMN "enabled" BOOLEAN NOT NULL DEFAULT true;
3 changes: 3 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ model WorkflowTriggerCronRef {
// the cron expression
cron String
// whether this cron is enabled or not
enabled Boolean @default(true)
// the assigned ticker
ticker Ticker? @relation(fields: [tickerId], references: [id])
tickerId String? @db.Uuid
Expand Down

0 comments on commit 519167e

Please sign in to comment.