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

Adiciona um novo operador que irá enviar um e-mail após todos os passos do processamento excutado. #307

Merged
merged 1 commit into from
Nov 11, 2021
Merged
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
22 changes: 21 additions & 1 deletion airflow/dags/sync_kernel_to_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from airflow.models import Variable
from airflow.operators.python_operator import PythonOperator, ShortCircuitOperator
from airflow.operators.dagrun_operator import TriggerDagRunOperator
from airflow.operators.email_operator import EmailOperator

from opac_schema.v1 import models

Expand All @@ -22,7 +23,15 @@
)
from common.hooks import mongo_connect, kernel_connect

email_notification_recipients = os.environ.get(
"EMAIL_NOTIFICATION_RECIPIENTS", None)

EMAIL_NOTIFICATION_RECIPIENTS = (
email_notification_recipients.split(",") if email_notification_recipients else []
)

failure_recipients = os.environ.get("EMIAL_ON_FAILURE_RECIPIENTS", None)

EMIAL_ON_FAILURE_RECIPIENTS = (
failure_recipients.split(",") if failure_recipients else []
)
Expand Down Expand Up @@ -915,6 +924,15 @@ def register_last_issues(ds, **kwargs):
dag=dag,
)

send_notification_email = EmailOperator(
task_id='send_notification_email',
to=EMAIL_NOTIFICATION_RECIPIENTS,
subject='Site atualizado',
html_content=""" <h3>Site <a href="https://www.scielo.br">https://www.scielo.br</a> atualizado.</h3> """,
mime_charset='utf-8',
dag=dag
)

trigger_check_website_dag_task = TriggerDagRunOperator(
task_id="trigger_check_website_dag_task",
trigger_dag_id="check_website",
Expand All @@ -939,4 +957,6 @@ def register_last_issues(ds, **kwargs):

register_last_issues_task << delete_documents_task

register_last_issues_task >> trigger_check_website_dag_task
send_notification_email << register_last_issues_task

send_notification_email >> trigger_check_website_dag_task