From 5d5cdf2043149f0a59c18d8fd1b7e9c379d9d605 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:19:09 +0530 Subject: [PATCH] Move the admin subscription after the adv. settings (#599) * Move the admin subscription after the adv. settings * fix sql script * fix typo --- .../apis/advanced_settings/serializers.py | 2 ++ apps/workspaces/views.py | 1 - .../scripts/028-remove-admin-subscription.sql | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 scripts/sql/scripts/028-remove-admin-subscription.sql diff --git a/apps/workspaces/apis/advanced_settings/serializers.py b/apps/workspaces/apis/advanced_settings/serializers.py index 72c88082..a55b42a0 100644 --- a/apps/workspaces/apis/advanced_settings/serializers.py +++ b/apps/workspaces/apis/advanced_settings/serializers.py @@ -1,4 +1,5 @@ from rest_framework import serializers +from django_q.tasks import async_task from apps.workspaces.models import Configuration, Workspace, WorkspaceSchedule from apps.mappings.models import GeneralMapping @@ -183,6 +184,7 @@ def update(self, instance, validated): instance.save() AdvancedConfigurationsTriggers.post_to_integration_settings(instance.id, True) + async_task('apps.workspaces.tasks.async_create_admin_subcriptions', instance.id) return instance diff --git a/apps/workspaces/views.py b/apps/workspaces/views.py index ba8e4499..89e98d48 100644 --- a/apps/workspaces/views.py +++ b/apps/workspaces/views.py @@ -106,7 +106,6 @@ def post(self, request): workspace_id=workspace.id, cluster_domain=cluster_domain ) - async_task('apps.workspaces.tasks.async_create_admin_subcriptions', workspace.id) return Response( data=WorkspaceSerializer(workspace).data, diff --git a/scripts/sql/scripts/028-remove-admin-subscription.sql b/scripts/sql/scripts/028-remove-admin-subscription.sql new file mode 100644 index 00000000..e4a56d38 --- /dev/null +++ b/scripts/sql/scripts/028-remove-admin-subscription.sql @@ -0,0 +1,19 @@ +\copy (select fyle_org_id from workspaces where onboarding_state = 'COMPLETE') to '/Users/hrishabh/Desktop/orgs_netsuite.csv' WITH CSV HEADER; + + +-- Fyle DB +rollback; +begin; + +create temp table temp_orgs ( + org_id TEXT +); + +--- update path here +\copy temp_orgs(org_id) from '/Users/hrishabh/Desktop/orgs_netsuite.csv' WITH CSV HEADER; + +update platform_schema.admin_subscriptions set is_enabled = 'f' where org_id not in ( + select org_id from temp_orgs +) +and is_enabled = 't' +and webhook_url ilike '%netsuite-api%'; \ No newline at end of file