From e0a30c765106060edb5e60b25134a5aa2c880d21 Mon Sep 17 00:00:00 2001 From: Chaya Malik Date: Tue, 21 Nov 2023 13:10:12 -0500 Subject: [PATCH] DEVPROD-981 Support notifications when SUCCESSFUL task exceeds some duration (#2155) --- src/components/Notifications/form/event.ts | 5 ++++- src/constants/triggers.ts | 18 +++++++++++++++++- src/types/triggers.ts | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/Notifications/form/event.ts b/src/components/Notifications/form/event.ts index 229f14b97f..d424746f7a 100644 --- a/src/components/Notifications/form/event.ts +++ b/src/components/Notifications/form/event.ts @@ -380,7 +380,10 @@ export const getEventSchema = ( { properties: { eventSelect: { - enum: [ProjectTriggers.TASK_EXCEEDS_DURATION], + enum: [ + ProjectTriggers.TASK_EXCEEDS_DURATION, + ProjectTriggers.SUCCESSFUL_TASK_EXCEEDS_DURATION, + ], }, extraFields: { type: "object" as "object", diff --git a/src/constants/triggers.ts b/src/constants/triggers.ts index 01f25270fe..67f81fab53 100644 --- a/src/constants/triggers.ts +++ b/src/constants/triggers.ts @@ -306,10 +306,25 @@ export const projectTriggers: Trigger = { failureTypeSubscriberConfig, ], }, + [ProjectTriggers.SUCCESSFUL_TASK_EXCEEDS_DURATION]: { + trigger: TriggerType.SUCCESSFUL_EXCEEDS_DURATION, + resourceType: ResourceType.Task, + label: "The Runtime For a Successful Task Exceeds Some Duration", + regexSelectors: taskRegexSelectors, + extraFields: [ + { + text: "Task Duration (Seconds)", + fieldType: "input", + key: ExtraFieldKey.TASK_DURATION_SECS, + format: "number", + default: "10", + }, + ], + }, [ProjectTriggers.TASK_EXCEEDS_DURATION]: { trigger: TriggerType.EXCEEDS_DURATION, resourceType: ResourceType.Task, - label: "The Runtime For a Task Exceeds Some Duration", + label: "The Runtime For Any Task Exceeds Some Duration", regexSelectors: taskRegexSelectors, extraFields: [ { @@ -408,6 +423,7 @@ export const triggerToCopy = { [TriggerType.FAMILY_SUCCESS]: "Success", [TriggerType.RUNTIME_CHANGE]: "Runtime changes by %", [TriggerType.EXCEEDS_DURATION]: "Runtime exceeds duration", + [TriggerType.SUCCESSFUL_EXCEEDS_DURATION]: "Runtime exceeds duration", [TriggerType.TASK_STARTED]: "Task started", [TriggerType.TASK_FAILED_OR_BLOCKED]: "Task failed or blocked", [TriggerType.REGRESSION]: "Regression", diff --git a/src/types/triggers.ts b/src/types/triggers.ts index 1ba9d1c51a..6af2bcdf85 100644 --- a/src/types/triggers.ts +++ b/src/types/triggers.ts @@ -22,6 +22,7 @@ export enum TriggerType { FAMILY_SUCCESS = "family-success", RUNTIME_CHANGE = "runtime-change", EXCEEDS_DURATION = "exceeds-duration", + SUCCESSFUL_EXCEEDS_DURATION = "successful-exceeds-duration", TASK_STARTED = "task-started", TASK_FAILED_OR_BLOCKED = "task-failed-or-blocked", REGRESSION = "regression", @@ -67,6 +68,7 @@ export enum ProjectTriggers { PREVIOUS_PASSING_TASK_FAILS = "previous-passing-task-fails", PREVIOUS_PASSING_TEST_FAILS = "previous-passing-test-fails", TASK_EXCEEDS_DURATION = "project-task-exceeds-duration", + SUCCESSFUL_TASK_EXCEEDS_DURATION = "successful-project-task-exceeds-duration", SUCCESSFUL_TASK_RUNTIME_CHANGES = "successful-task-runtime-change", }