Skip to content

Commit

Permalink
Merge pull request #439 from dfpc-coe/remove-cron
Browse files Browse the repository at this point in the history
Remove Event Cron
  • Loading branch information
ingalls authored Dec 6, 2024
2 parents 9973ae2 + 223ace2 commit 2529c59
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 118 deletions.
12 changes: 7 additions & 5 deletions api/routes/connection-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default async function router(schema: Schema, config: Config) {
description: Default.DescriptionField,
enabled: Type.Optional(Type.Boolean()),
task: Type.String(),
cron: Type.String(),
cron: Type.Optional(Type.String()),
logging: Type.Boolean(),
stale: Type.Optional(Type.Integer()),
data: Type.Optional(Type.Integer()),
Expand Down Expand Up @@ -203,7 +203,7 @@ export default async function router(schema: Schema, config: Config) {
if (config.events) {
if (layer.cron && !Schedule.is_aws(layer.cron) && layer.enabled) {
config.events.add(layer.id, layer.cron);
} else if (layer.cron && Schedule.is_aws(layer.cron) || !layer.enabled) {
} else if (!layer.cron || (layer.cron && Schedule.is_aws(layer.cron)) || !layer.enabled) {
await config.events.delete(layer.id);
}
}
Expand Down Expand Up @@ -255,7 +255,7 @@ export default async function router(schema: Schema, config: Config) {
priority: Type.Optional(Type.Enum(Layer_Priority)),
description: Type.Optional(Default.DescriptionField),
webhooks: Type.Optional(Type.Boolean()),
cron: Type.Optional(Type.String()),
cron: Type.Optional(Type.Union([Type.String(), Type.Null()])),
memory: Type.Optional(Type.Integer()),
timeout: Type.Optional(Type.Integer()),
enabled: Type.Optional(Type.Boolean()),
Expand Down Expand Up @@ -313,7 +313,9 @@ export default async function router(schema: Schema, config: Config) {
await Style.validate(req.body.styles);
}

if (req.body.cron) Schedule.is_valid(req.body.cron);
if (req.body.cron) {
Schedule.is_valid(req.body.cron);
}

if (layer.connection !== connection.id) {
throw new Err(400, null, 'Layer does not belong to this connection');
Expand Down Expand Up @@ -352,7 +354,7 @@ export default async function router(schema: Schema, config: Config) {
if (config.events) {
if (layer.cron && !Schedule.is_aws(layer.cron) && layer.enabled) {
config.events.add(layer.id, layer.cron);
} else if (layer.cron && Schedule.is_aws(layer.cron) || !layer.enabled) {
} else if (!layer.cron || (layer.cron && Schedule.is_aws(layer.cron)) || !layer.enabled) {
await config.events.delete(layer.id);
}
}
Expand Down
Loading

0 comments on commit 2529c59

Please sign in to comment.