From 110908693e6ab62dff60d63db32f0029abffb54d Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 21 Feb 2023 18:57:09 +0100 Subject: [PATCH] feat(chalice): fixes --- api/chalicelib/core/metadata.py | 8 ++++---- api/chalicelib/core/webhook.py | 10 +++++----- ee/api/chalicelib/core/roles.py | 10 +++++----- ee/api/chalicelib/core/webhook.py | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/api/chalicelib/core/metadata.py b/api/chalicelib/core/metadata.py index 7b426cddb..f5ed9599f 100644 --- a/api/chalicelib/core/metadata.py +++ b/api/chalicelib/core/metadata.py @@ -22,10 +22,10 @@ def __exists_by_name(project_id: int, name: str, exclude_index: Optional[int]) - for c in constraints: c += " ILIKE %(name)s" query = cur.mogrify(f"""SELECT EXISTS(SELECT 1 - FROM public.projects - WHERE project_id = %(project_id)s - AND deleted_at ISNULL - AND ({" OR ".join(constraints)})) AS exists;""", + FROM public.projects + WHERE project_id = %(project_id)s + AND deleted_at ISNULL + AND ({" OR ".join(constraints)})) AS exists;""", {"project_id": project_id, "name": name}) cur.execute(query=query) row = cur.fetchone() diff --git a/api/chalicelib/core/webhook.py b/api/chalicelib/core/webhook.py index 8ce166b03..d0ed97d08 100644 --- a/api/chalicelib/core/webhook.py +++ b/api/chalicelib/core/webhook.py @@ -110,11 +110,11 @@ def exists_by_name(name: str, exclude_id: Optional[int], webhook_type: str = sch tenant_id: Optional[int] = None) -> bool: with pg_client.PostgresClient() as cur: query = cur.mogrify(f"""SELECT EXISTS(SELECT 1 - FROM public.webhooks - WHERE name ILIKE %(name)s - AND deleted_at ISNULL - AND type=%(webhook_type)s - {"AND webhook_id!=%(exclude_id))s" if exclude_id else ""}) AS exists;""", + FROM public.webhooks + WHERE name ILIKE %(name)s + AND deleted_at ISNULL + AND type=%(webhook_type)s + {"AND webhook_id!=%(exclude_id)s" if exclude_id else ""}) AS exists;""", {"name": name, "exclude_id": exclude_id, "webhook_type": webhook_type}) cur.execute(query) row = cur.fetchone() diff --git a/ee/api/chalicelib/core/roles.py b/ee/api/chalicelib/core/roles.py index 9b8a9b56e..79f1caec7 100644 --- a/ee/api/chalicelib/core/roles.py +++ b/ee/api/chalicelib/core/roles.py @@ -12,11 +12,11 @@ from chalicelib.utils.TimeUTC import TimeUTC def __exists_by_name(tenant_id: int, name: str, exclude_id: Optional[int]) -> bool: with pg_client.PostgresClient() as cur: query = cur.mogrify(f"""SELECT EXISTS(SELECT 1 - FROM public.roles - WHERE tenant_id = %(tenant_id)s - AND name ILIKE %(name)s - AND deleted_at ISNULL - {"role_id!=%(exclude_id)s" if exclude_id else ""}) AS exists;""", + FROM public.roles + WHERE tenant_id = %(tenant_id)s + AND name ILIKE %(name)s + AND deleted_at ISNULL + {"AND role_id!=%(exclude_id)s" if exclude_id else ""}) AS exists;""", {"tenant_id": tenant_id, "name": name, "exclude_id": exclude_id}) cur.execute(query=query) row = cur.fetchone() diff --git a/ee/api/chalicelib/core/webhook.py b/ee/api/chalicelib/core/webhook.py index 584db9839..d1e70d3e7 100644 --- a/ee/api/chalicelib/core/webhook.py +++ b/ee/api/chalicelib/core/webhook.py @@ -116,12 +116,12 @@ def exists_by_name(tenant_id: int, name: str, exclude_id: Optional[int], webhook_type: str = schemas.WebhookType.webhook) -> bool: with pg_client.PostgresClient() as cur: query = cur.mogrify(f"""SELECT EXISTS(SELECT 1 - FROM public.webhooks - WHERE name ILIKE %(name)s - AND deleted_at ISNULL - AND tenant_id=%(tenant_id)s - AND type=%(webhook_type)s - {"AND webhook_id!=%(exclude_id))s" if exclude_id else ""}) AS exists;""", + FROM public.webhooks + WHERE name ILIKE %(name)s + AND deleted_at ISNULL + AND tenant_id=%(tenant_id)s + AND type=%(webhook_type)s + {"AND webhook_id!=%(exclude_id)s" if exclude_id else ""}) AS exists;""", {"tenant_id": tenant_id, "name": name, "exclude_id": exclude_id, "webhook_type": webhook_type}) cur.execute(query)