From 8530f7c100ceefe5292bd43b2d5fdd39cdf8b487 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 27 Mar 2023 10:00:46 +0100 Subject: [PATCH 1/3] feat(chalice): removed integrations from projects response --- api/chalicelib/core/projects.py | 1 + ee/api/chalicelib/core/projects.py | 1 + 2 files changed, 2 insertions(+) diff --git a/api/chalicelib/core/projects.py b/api/chalicelib/core/projects.py index 24d1e01f7..82103ce9c 100644 --- a/api/chalicelib/core/projects.py +++ b/api/chalicelib/core/projects.py @@ -54,6 +54,7 @@ def __create(tenant_id, name): def get_projects(tenant_id, recording_state=False, gdpr=None, recorded=False, stack_integrations=False): + stack_integrations = False with pg_client.PostgresClient() as cur: extra_projection = "" extra_join = "" diff --git a/ee/api/chalicelib/core/projects.py b/ee/api/chalicelib/core/projects.py index dc06703ce..6b0628de7 100644 --- a/ee/api/chalicelib/core/projects.py +++ b/ee/api/chalicelib/core/projects.py @@ -55,6 +55,7 @@ def __create(tenant_id, name): def get_projects(tenant_id, recording_state=False, gdpr=None, recorded=False, stack_integrations=False, user_id=None): + stack_integrations = False with pg_client.PostgresClient() as cur: role_query = """INNER JOIN LATERAL (SELECT 1 FROM users From 07aeff5ab1f8ab9782ef7c8c28e19517dbc097ad Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 27 Mar 2023 11:59:29 +0100 Subject: [PATCH 2/3] feat(chalice): remove signup endpoint if tenant exists --- api/routers/core.py | 6 ------ api/routers/core_dynamic.py | 9 ++++++++- ee/api/routers/core_dynamic.py | 9 ++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/api/routers/core.py b/api/routers/core.py index a23e437ea..58819a811 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -663,12 +663,6 @@ async def mobile_signe(projectId: int, sessionId: int, data: schemas.MobileSignP return {"data": mobile.sign_keys(project_id=projectId, session_id=sessionId, keys=data.keys)} -@public_app.post('/signup', tags=['signup']) -@public_app.put('/signup', tags=['signup']) -async def signup_handler(data: schemas.UserSignupSchema = Body(...)): - return signup.create_step1(data) - - @app.post('/projects', tags=['projects']) async def create_project(data: schemas.CreateProjectSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): diff --git a/api/routers/core_dynamic.py b/api/routers/core_dynamic.py index c6f71e88f..f4d5e9a62 100644 --- a/api/routers/core_dynamic.py +++ b/api/routers/core_dynamic.py @@ -6,7 +6,7 @@ from starlette.responses import RedirectResponse, FileResponse import schemas from chalicelib.core import sessions, errors, errors_viewed, errors_favorite, sessions_assignments, heatmaps, \ - sessions_favorite, assist, sessions_notes, click_maps, sessions_replay + sessions_favorite, assist, sessions_notes, click_maps, sessions_replay, signup from chalicelib.core import sessions_viewed from chalicelib.core import tenants, users, projects, license from chalicelib.core import webhook @@ -27,6 +27,13 @@ async def get_all_signup(): "edition": license.EDITION}} +if not tenants.tenants_exists(use_pool=False): + @public_app.post('/signup', tags=['signup']) + @public_app.put('/signup', tags=['signup']) + async def signup_handler(data: schemas.UserSignupSchema = Body(...)): + return signup.create_step1(data) + + @app.get('/account', tags=['accounts']) async def get_account(context: schemas.CurrentContext = Depends(OR_context)): r = users.get(tenant_id=context.tenant_id, user_id=context.user_id) diff --git a/ee/api/routers/core_dynamic.py b/ee/api/routers/core_dynamic.py index 209fdbd6d..34c517ee8 100644 --- a/ee/api/routers/core_dynamic.py +++ b/ee/api/routers/core_dynamic.py @@ -7,7 +7,7 @@ from starlette.responses import RedirectResponse, FileResponse import schemas import schemas_ee from chalicelib.core import sessions, assist, heatmaps, sessions_favorite, sessions_assignments, errors, errors_viewed, \ - errors_favorite, sessions_notes, click_maps, sessions_replay + errors_favorite, sessions_notes, click_maps, sessions_replay, signup from chalicelib.core import sessions_viewed from chalicelib.core import tenants, users, projects, license from chalicelib.core import webhook @@ -31,6 +31,13 @@ async def get_all_signup(): "edition": license.EDITION}} +if not tenants.tenants_exists(use_pool=False): + @public_app.post('/signup', tags=['signup']) + @public_app.put('/signup', tags=['signup']) + async def signup_handler(data: schemas.UserSignupSchema = Body(...)): + return signup.create_step1(data) + + @app.get('/account', tags=['accounts']) async def get_account(context: schemas.CurrentContext = Depends(OR_context)): r = users.get(tenant_id=context.tenant_id, user_id=context.user_id) From 5c07b1037f6055df0754f8d6337c08eb5e8a7f83 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 27 Mar 2023 12:36:29 +0100 Subject: [PATCH 3/3] feat(DB): delta lock tables before structural changes --- .../schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql | 13 ++++++++----- .../schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql index 21544f62c..a8b7a297b 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql @@ -22,10 +22,18 @@ $$ SELECT 'v1.11.0-ee' $$ LANGUAGE sql IMMUTABLE; +ALTER TYPE issue_type ADD VALUE IF NOT EXISTS 'mouse_thrashing'; + +LOCK TABLE ONLY events.inputs IN ACCESS EXCLUSIVE MODE; ALTER TABLE events.inputs ADD COLUMN duration integer NULL, ADD COLUMN hesitation integer NULL; +LOCK TABLE ONLY events.clicks IN ACCESS EXCLUSIVE MODE; +ALTER TABLE events.clicks + ADD COLUMN hesitation integer NULL; + +LOCK TABLE ONLY public.projects IN ACCESS EXCLUSIVE MODE; ALTER TABLE public.projects ALTER COLUMN gdpr SET DEFAULT '{ "maskEmails": true, @@ -34,9 +42,4 @@ ALTER TABLE public.projects "defaultInputMode": "obscured" }'::jsonb; -ALTER TYPE issue_type ADD VALUE IF NOT EXISTS 'mouse_thrashing'; - -ALTER TABLE events.clicks - ADD COLUMN hesitation integer NULL; - COMMIT; \ No newline at end of file diff --git a/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql b/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql index 0fde93c48..d0bfd18e2 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.11.0/1.11.0.sql @@ -22,10 +22,18 @@ $$ SELECT 'v1.11.0' $$ LANGUAGE sql IMMUTABLE; +ALTER TYPE issue_type ADD VALUE IF NOT EXISTS 'mouse_thrashing'; + +LOCK TABLE ONLY events.inputs IN ACCESS EXCLUSIVE MODE; ALTER TABLE events.inputs ADD COLUMN duration integer NULL, ADD COLUMN hesitation integer NULL; +LOCK TABLE ONLY events.clicks IN ACCESS EXCLUSIVE MODE; +ALTER TABLE events.clicks + ADD COLUMN hesitation integer NULL; + +LOCK TABLE ONLY public.projects IN ACCESS EXCLUSIVE MODE; ALTER TABLE public.projects ALTER COLUMN gdpr SET DEFAULT '{ "maskEmails": true, @@ -34,9 +42,4 @@ ALTER TABLE public.projects "defaultInputMode": "obscured" }'::jsonb; -ALTER TYPE issue_type ADD VALUE IF NOT EXISTS 'mouse_thrashing'; - -ALTER TABLE events.clicks - ADD COLUMN hesitation integer NULL; - COMMIT; \ No newline at end of file