Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Querys(Enum):
flow_run(
where: {
flow_id: { _eq: $flow_id }
state: { _in: ["Success", "Failed"] }
state: { _in: ["Failed"] }
}
order_by: { start_time: desc }
limit: 2
Expand All @@ -39,7 +39,7 @@ class Querys(Enum):
state
task_runs(
where: {
state: { _in: ["Success", "Failed"] }
state: { _in: ["Failed"] }
}
order_by: { start_time: desc }
limit: 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def __init__(
self.name = name
self.start_time = parse_datetime(start_time)
self.state = state
self.task_runs = TaskRun(**task_runs[0])
self.task_runs = (
TaskRun(**task_runs[0]) if task_runs else None
) # Caso não tenha segundo Run


class FlowDisable:
Expand All @@ -58,7 +60,9 @@ def get_runs(self):
return [FlowRun(**run) for run in response["flow_run"]]

def validate(self) -> bool:
last_run, next_last = self.runs
last_run = self.runs[0]
next_last = self.runs[1] if len(self.runs) == 2 else None

failed = Constants.FLOW_FAILED_STATE.value

dbt_failed_after_created = (
Expand All @@ -68,10 +72,11 @@ def validate(self) -> bool:
and last_run.task_runs.state_message not in Constants.STATE_MESSAGE_IGNORE.value
)

any_failed_after_created = (
last_run.state == failed
consecutive_failed_after_created = (
next_last
and last_run.state == failed
and next_last.state == failed
and max(last_run.start_time, next_last.start_time) >= self.created
)

return dbt_failed_after_created or any_failed_after_created
return bool(dbt_failed_after_created or consecutive_failed_after_created)
Loading