From 0b9da5c8a3bdf23681bfdfb132d5fbe1b160241a Mon Sep 17 00:00:00 2001 From: Rohit Chatterjee Date: Wed, 18 Dec 2024 10:22:04 +0530 Subject: [PATCH] removed unused imports put connection name into schema-change email --- ddpui/celeryworkers/tasks.py | 5 +++-- ddpui/ddpairbyte/airbytehelpers.py | 5 ++--- ddpui/tests/core/test_celery_tasks.py | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ddpui/celeryworkers/tasks.py b/ddpui/celeryworkers/tasks.py index 8cae498a..4e720552 100644 --- a/ddpui/celeryworkers/tasks.py +++ b/ddpui/celeryworkers/tasks.py @@ -457,11 +457,12 @@ def detect_schema_changes_for_org(org: Org): if frontend_url.endswith("/"): frontend_url = frontend_url[:-1] connections_page = f"{frontend_url}/pipeline/ingest?tab=connections" + connection_name = connection_catalog["name"] notify_org_managers( org, f"To the admins of {org.name},\n\nThis email is to let you know that" - " schema changes have been detected in your Dalgo sources.\n\nPlease" - f" visit {connections_page} and review the Pending Actions", + f' schema changes have been detected in your Dalgo sources for "{connection_name}".' + f"\n\nPlease visit {connections_page} and review the Pending Actions", ) except Exception as err: logger.error(err) diff --git a/ddpui/ddpairbyte/airbytehelpers.py b/ddpui/ddpairbyte/airbytehelpers.py index 2937170c..883dc6f4 100644 --- a/ddpui/ddpairbyte/airbytehelpers.py +++ b/ddpui/ddpairbyte/airbytehelpers.py @@ -4,13 +4,13 @@ import json import os +from pathlib import Path import yaml from ninja.errors import HttpError -from pathlib import Path from django.utils.text import slugify from django.conf import settings from django.db import transaction -from django.db.models import Prefetch, F, Window, Q +from django.db.models import F, Window, Q from django.db.models.functions import RowNumber from django.forms.models import model_to_dict @@ -57,7 +57,6 @@ from ddpui.utils.helpers import ( generate_hash_id, update_dict_but_not_stars, - map_airbyte_keys_to_postgres_keys, get_schedule_time_for_large_jobs, ) from ddpui.utils import secretsmanager diff --git a/ddpui/tests/core/test_celery_tasks.py b/ddpui/tests/core/test_celery_tasks.py index 58c3ab40..3c601eaf 100644 --- a/ddpui/tests/core/test_celery_tasks.py +++ b/ddpui/tests/core/test_celery_tasks.py @@ -384,7 +384,10 @@ def test_detect_schema_changes_for_org_send_schema_changes_email( ) as fetch_and_update_org_schema_changes_mock, patch( "ddpui.celeryworkers.tasks.notify_org_managers" ) as notify_org_managers_mock: - fetch_and_update_org_schema_changes_mock.return_value = {"schemaChange": "breaking"}, None + fetch_and_update_org_schema_changes_mock.return_value = { + "schemaChange": "breaking", + "name": "CONN_NAME", + }, None orguser.org = org_without_workspace role = Role.objects.filter(slug="account-manager").first() if role is None: @@ -398,7 +401,7 @@ def test_detect_schema_changes_for_org_send_schema_changes_email( notify_org_managers_mock.assert_called_once_with( org_without_workspace, - f"To the admins of {org_without_workspace.name},\n\nThis email is to let you know that schema changes have been detected in your Dalgo sources.\n\nPlease visit {connections_page} and review the Pending Actions", + f'To the admins of {org_without_workspace.name},\n\nThis email is to let you know that schema changes have been detected in your Dalgo sources for "CONN_NAME".\n\nPlease visit {connections_page} and review the Pending Actions', )