From 2b34db6204fe00207738b6bebfa70b6f96a689d3 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 12:53:56 +0530 Subject: [PATCH 1/7] changes for interface --- documentation/3.1.0/native/MentorEd-Setup-README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/3.1.0/native/MentorEd-Setup-README.md b/documentation/3.1.0/native/MentorEd-Setup-README.md index 8f9e3502..83487317 100644 --- a/documentation/3.1.0/native/MentorEd-Setup-README.md +++ b/documentation/3.1.0/native/MentorEd-Setup-README.md @@ -188,7 +188,7 @@ Before setting up the application, the dependencies should be installed and veri git clone -b release-3.1.0 https://github.com/ELEVATE-Project/mentoring.git && \ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/user.git && \ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/notification.git && \ - git clone -b release-3.1.1 https://github.com/ELEVATE-Project/interface-service.git && \ + git clone -b release-3.1.0 https://github.com/ELEVATE-Project/interface-service.git && \ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/scheduler.git && \ git clone -b release-3.1.1 https://github.com/ELEVATE-Project/mentoring-mobile-app.git ``` @@ -199,7 +199,7 @@ Before setting up the application, the dependencies should be installed and veri git clone -b release-3.1.0 https://github.com/ELEVATE-Project/mentoring.git & ^ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/user.git & ^ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/notification.git & ^ - git clone -b release-3.1.1 https://github.com/ELEVATE-Project/interface-service.git & ^ + git clone -b release-3.1.0 https://github.com/ELEVATE-Project/interface-service.git & ^ git clone -b release-3.1.0 https://github.com/ELEVATE-Project/scheduler.git & ^ git clone -b release-3.1.1 https://github.com/ELEVATE-Project/mentoring-mobile-app.git ``` From b8e002199c67262f144a5a8a5b71a3e7dc9a389c Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 13:10:36 +0530 Subject: [PATCH 2/7] interface env changes --- documentation/3.1.0/native/envs/interface_env | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/documentation/3.1.0/native/envs/interface_env b/documentation/3.1.0/native/envs/interface_env index eca68c85..f4c68259 100644 --- a/documentation/3.1.0/native/envs/interface_env +++ b/documentation/3.1.0/native/envs/interface_env @@ -1,16 +1,15 @@ API_DOC_URL=/elevate-interface/api-doc APPLICATION_ENV=development APPLICATION_PORT=3569 -INSTALLED_PACKAGES=elevate-user elevate-mentoring elevate-scheduler +INSTALLED_PACKAGES=elevate-user elevate-mentoring elevate-scheduler elevate-project elevate-entity-management elevate-self-creation-portal elevate-survey MENTORING_SERVICE_BASE_URL=http://localhost:3000 NOTIFICATION_SERVICE_BASE_URL=http://localhost:3002 RATE_LIMITER_ENABLED=true RATE_LIMITER_NUMBER_OF_PROXIES=0 -REQUIRED_BASE_PACKAGES=elevate-user elevate-mentoring elevate-scheduler -REQUIRED_PACKAGES=elevate-user@1.1.71 elevate-mentoring@1.1.56 elevate-scheduler@1.0.4 -ROUTE_CONFIG_JSON_URLS_PATHS=https://raw.githubusercontent.com/ELEVATE-Project/user/develop/src/constants/interface-routes/configs.json,https://raw.githubusercontent.com/ELEVATE-Project/mentoring/release-3.2.0/src/constants/interface-routes/configs.json,https://raw.githubusercontent.com/ELEVATE-Project/scheduler/develop/src/constants/interface-routes/configs.json +REQUIRED_PACKAGES=elevate-user@1.1.71 elevate-mentoring@1.1.56 elevate-scheduler@1.0.4 elevate-project@1.1.16 elevate-entity-management@1.0.7 elevate-self-creation-portal@1.0.30 elevate-survey@1.0.27 SCHEDULER_SERVICE_BASE_URL=http://localhost:4000 SUPPORTED_HTTP_TYPES="GET POST PUT PATCH DELETE" USER_SERVICE_BASE_URL=http://localhost:3001 +SELF_CREATION_PORTAL_SERVICE_BASE_URL=http://localhost:3006 ALLOWED_HOST="*" INTERNAL_ACCESS_TOKEN=internal_access_token \ No newline at end of file From 511c457a81e98d6494c1d709fbc28f0d2b07b84c Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 13:22:07 +0530 Subject: [PATCH 3/7] scheduler env changes --- documentation/3.1.0/native/envs/scheduler_env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/3.1.0/native/envs/scheduler_env b/documentation/3.1.0/native/envs/scheduler_env index 6f02665a..ec6361b2 100644 --- a/documentation/3.1.0/native/envs/scheduler_env +++ b/documentation/3.1.0/native/envs/scheduler_env @@ -6,7 +6,7 @@ DEFAULT_QUEUE=email DISABLE_LOG=false ENABLE_LOG=true ERROR_LOG_LEVEL=silly -KAFKA_URL=kafka:9092 +KAFKA_URL=localhost:9092 NOTIFICATION_KAFKA_TOPIC=notifications -REDIS_HOST=redis +REDIS_HOST=localhost REDIS_PORT=6379 From 60709a06267ac9f7aee2f10331dddc8e3b172c64 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 13:26:19 +0530 Subject: [PATCH 4/7] notification env changes --- documentation/3.1.0/native/envs/notification_env | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/documentation/3.1.0/native/envs/notification_env b/documentation/3.1.0/native/envs/notification_env index 4d9b1249..58ea8fbb 100644 --- a/documentation/3.1.0/native/envs/notification_env +++ b/documentation/3.1.0/native/envs/notification_env @@ -8,8 +8,7 @@ ENABLE_LOG=true ERROR_LOG_LEVEL=silly INTERNAL_ACCESS_TOKEN=internal_access_token KAFKA_GROUP_ID=notification -KAFKA_HOST=kafka:9092 +KAFKA_HOST=localhost:9092 KAFKA_TOPIC=develop.notifications -ZEST_ENV="ZEST_ENV" SENDGRID_API_KEY=asd9f87a SENDGRID_FROM_MAIL=no-reply@some.org From 7e3f4df582aaf594f2fa2cef8f2c63452b5cac41 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 13:58:11 +0530 Subject: [PATCH 5/7] user env and insert data changes --- documentation/3.1.0/native/envs/non-citus/user_env | 14 +++++++++----- documentation/3.1.0/native/envs/user_env | 12 ++++++++---- .../native/scripts/linux/insert_sample_data.sh | 6 +++--- .../native/scripts/macos/insert_sample_data.sh | 6 +++--- .../native/scripts/windows/insert_sample_data.bat | 6 +++--- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/documentation/3.1.0/native/envs/non-citus/user_env b/documentation/3.1.0/native/envs/non-citus/user_env index 450241d3..4da51d72 100644 --- a/documentation/3.1.0/native/envs/non-citus/user_env +++ b/documentation/3.1.0/native/envs/non-citus/user_env @@ -1,8 +1,10 @@ ACCESS_TOKEN_EXPIRY=30m -ACCESS_TOKEN_SECRET=xG7V87nfj2394fJD394jfgh08dfDfh98DKJlndfj9d # Replace with your secure secret +# Replace with your secure secret +ACCESS_TOKEN_SECRET=xG7V87nfj2394fJD394jfgh08dfDfh98DKJlndfj9d ADMIN_INVITEE_UPLOAD_EMAIL_TEMPLATE_CODE=invitee_upload_status -ADMIN_SECRET_CODE=N0DM5NAwwCN5KNXKJwlwu6c0nQQt6Rcl # Replace with secure admin secret code +# Replace with secure admin secret code ALLOWED_HOST="*" +ADMIN_SECRET_CODE=N0DM5NAwwCN5KNXKJwlwu6c0nQQt6Rcl API_DOC_URL=/user/api-doc APPLICATION_BASE_URL=/user APPLICATION_ENV=development @@ -25,7 +27,7 @@ DEFAULT_ORGANISATION_CODE=default_code DEFAULT_ORG_ID=1 DEFAULT_QUEUE=queue DEFAULT_ROLE=mentee -DEV_DATABASE_URL=postgres://postgres:postgres@localhost:5432/users +DEV_DATABASE_URL=postgres://postgres:postgres@localhost:9700/users DISABLE_LOG=false EMAIL_ID_ENCRYPTION_ALGORITHM="aes-256-cbc" EMAIL_ID_ENCRYPTION_IV=c9c7bd480494409071847264652f5c95 @@ -57,10 +59,12 @@ OTP_EMAIL_TEMPLATE_CODE=emailotp OTP_EXP_TIME=86400 PORTAL_URL=https://mentored.some.org/auth/login PUBLIC_ASSET_BUCKETNAME="public-bucket" -RECAPTCHA_SECRET_KEY=6LfWEKYpAAAAAJS0eukS2Su # Replace with secure Recaptcha secret key REDIS_HOST=redis://localhost:6379 +# Replace with secure Recaptcha secret key +RECAPTCHA_SECRET_KEY=6LfWEKYpAAAAAJS0eukS2Su REFRESH_TOKEN_EXPIRY=7 -REFRESH_TOKEN_SECRET=371hkjkjady2y3ihdkajshdkiq23iuekw71 # Replace with secure refresh token secret +# Replace with secure refresh token secret +REFRESH_TOKEN_SECRET=371hkjkjady2y3ihdkajshdkiq23iuekw71 REFRESH_VIEW_INTERVAL=540000 REGISTRATION_EMAIL_TEMPLATE_CODE=registration REGISTRATION_OTP_EMAIL_TEMPLATE_CODE=registrationotp diff --git a/documentation/3.1.0/native/envs/user_env b/documentation/3.1.0/native/envs/user_env index edc07c87..4c31511b 100644 --- a/documentation/3.1.0/native/envs/user_env +++ b/documentation/3.1.0/native/envs/user_env @@ -1,7 +1,9 @@ ACCESS_TOKEN_EXPIRY=30m -ACCESS_TOKEN_SECRET=xG7V87nfj2394fJD394jfgh08dfDfh98DKJlndfj9d # Replace with your secure secret +# Replace with your secure secret +ACCESS_TOKEN_SECRET=xG7V87nfj2394fJD394jfgh08dfDfh98DKJlndfj9d ADMIN_INVITEE_UPLOAD_EMAIL_TEMPLATE_CODE=invitee_upload_status -ADMIN_SECRET_CODE=N0DM5NAwwCN5KNXKJwlwu6c0nQQt6Rcl # Replace with secure admin secret code +# Replace with your secure secret +ADMIN_SECRET_CODE=N0DM5NAwwCN5KNXKJwlwu6c0nQQt6Rcl ALLOWED_HOST="*" API_DOC_URL=/user/api-doc APPLICATION_BASE_URL=/user @@ -57,10 +59,12 @@ OTP_EMAIL_TEMPLATE_CODE=emailotp OTP_EXP_TIME=86400 PORTAL_URL=https://mentored.some.org/auth/login PUBLIC_ASSET_BUCKETNAME="public-bucket" -RECAPTCHA_SECRET_KEY=6LfWEKYpAAAAAJS0eukS2Su # Replace with secure Recaptcha secret key +# Replace with secure Recaptcha secret key +RECAPTCHA_SECRET_KEY=6LfWEKYpAAAAAJS0eukS2Su REDIS_HOST=redis://localhost:6379 REFRESH_TOKEN_EXPIRY=7 -REFRESH_TOKEN_SECRET=371hkjkjady2y3ihdkajshdkiq23iuekw71 # Replace with secure refresh token secret +# Replace with secure refresh token secret +REFRESH_TOKEN_SECRET=371hkjkjady2y3ihdkajshdkiq23iuekw71 REFRESH_VIEW_INTERVAL=540000 REGISTRATION_EMAIL_TEMPLATE_CODE=registration REGISTRATION_OTP_EMAIL_TEMPLATE_CODE=registrationotp diff --git a/documentation/3.1.0/native/scripts/linux/insert_sample_data.sh b/documentation/3.1.0/native/scripts/linux/insert_sample_data.sh index 871cfa6c..72795437 100644 --- a/documentation/3.1.0/native/scripts/linux/insert_sample_data.sh +++ b/documentation/3.1.0/native/scripts/linux/insert_sample_data.sh @@ -11,6 +11,6 @@ sudo -u postgres psql -p 9700 -d users -c "INSERT INTO public.users_credentials sudo -u postgres psql -p 9700 -d users -c "SELECT nextval('users_id_seq'::regclass) FROM public.users;" sudo -u postgres psql -p 9700 -d users -c "SELECT nextval('users_credentials_id_seq'::regclass) FROM public.users_credentials;" -sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (6, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" -sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (4, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" -sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (5, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" +sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (1, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" +sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (2, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" +sudo -u postgres psql -p 9700 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (3, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" diff --git a/documentation/3.1.0/native/scripts/macos/insert_sample_data.sh b/documentation/3.1.0/native/scripts/macos/insert_sample_data.sh index 60b87b21..fb2edc16 100644 --- a/documentation/3.1.0/native/scripts/macos/insert_sample_data.sh +++ b/documentation/3.1.0/native/scripts/macos/insert_sample_data.sh @@ -11,6 +11,6 @@ psql -p 5432 -d users -c "INSERT INTO public.users_credentials (id, email, passw psql -p 5432 -d users -c "SELECT nextval('users_id_seq'::regclass) FROM public.users;" psql -p 5432 -d users -c "SELECT nextval('users_credentials_id_seq'::regclass) FROM public.users_credentials;" -psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (6, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" -psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (4, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" -psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (5, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" +psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (1, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" +psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (2, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" +psql -p 5432 -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (3, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" diff --git a/documentation/3.1.0/native/scripts/windows/insert_sample_data.bat b/documentation/3.1.0/native/scripts/windows/insert_sample_data.bat index d7a2db29..5ba20866 100644 --- a/documentation/3.1.0/native/scripts/windows/insert_sample_data.bat +++ b/documentation/3.1.0/native/scripts/windows/insert_sample_data.bat @@ -10,9 +10,9 @@ psql -p 5432 -U postgres -d users -c "INSERT INTO public.users_credentials (id, psql -p 5432 -U postgres -d users -c "SELECT nextval('users_id_seq'::regclass) FROM public.users;" psql -p 5432 -U postgres -d users -c "SELECT nextval('users_credentials_id_seq'::regclass) FROM public.users_credentials;" -psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (6, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" -psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (4, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" -psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (5, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" +psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (1, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, false, 'CURRENT','aaravpatel@example.com',9767887878,'Aarav Patel');" +psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (2, '{beo}', '{communication}', 'BA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '2', 1, true, 'CURRENT','arunimareddy@example.com',6456757768,'Arunima Reddy');" +psql -p 5432 -U postgres -d mentoring -c "INSERT INTO public.user_extensions (user_id, designation, area_of_expertise, education_qualification, rating, meta, stats, tags, configs, visible_to_organizations, external_session_visibility, external_mentor_visibility, custom_entity_text, created_at, updated_at, deleted_at, experience, organization_id, is_mentor, mentee_visibility, email, phone, name) VALUES (3, '{beo}', '{communication}', 'BCA', NULL, NULL, NULL, NULL, NULL, '{1}', 'CURRENT', 'CURRENT', NULL, '2024-04-18 09:09:48.938+00', '2024-04-18 09:10:07.028+00', NULL, '5', 1, false, 'CURRENT','aaravpatel@example.com',8756565656,'Devika Singh');" set PGPASSWORD= \ No newline at end of file From e9fa80019d8e33c0efb6415c344f648a4a1097a8 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 7 Nov 2024 16:12:28 +0530 Subject: [PATCH 6/7] script changes for forms --- documentation/3.1.0/dockerized/MentorEd-Setup-README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/3.1.0/dockerized/MentorEd-Setup-README.md b/documentation/3.1.0/dockerized/MentorEd-Setup-README.md index 6b3e1863..202d8329 100644 --- a/documentation/3.1.0/dockerized/MentorEd-Setup-README.md +++ b/documentation/3.1.0/dockerized/MentorEd-Setup-README.md @@ -287,13 +287,13 @@ There ar few forms required for mentoting application to run, to add those fallo - **Ubuntu/Linux/Mac** ``` - ./insert_sample_forms.sh mentoring postgres://postgres:postgres@citus_master:5432/mentoring + ./sample-data/mentoring/insert_sample_forms.sh mentoring postgres://postgres:postgres@citus_master:5432/mentoring ``` - **Windows** ``` - insert_sample_forms.bat mentoring postgres://postgres:postgres@citus_master:5432/mentoring + sample-data\mentoring\insert_sample_forms.bat mentoring postgres://postgres:postgres@citus_master:5432/mentoring ``` After successfully running the script, forms will be added to database. From c5d1f5bf7515784c6c654f3e0a9483ea439a27f8 Mon Sep 17 00:00:00 2001 From: sumanvpacewisdom Date: Thu, 14 Nov 2024 12:21:44 +0530 Subject: [PATCH 7/7] Windows forms insert script changes --- .../windows/create_default_form_sql.bat | 66 ++++--- .../scripts/windows/insert_sample_forms.bat | 166 +++++++++++------- 2 files changed, 130 insertions(+), 102 deletions(-) diff --git a/documentation/3.1.0/dockerized/scripts/windows/create_default_form_sql.bat b/documentation/3.1.0/dockerized/scripts/windows/create_default_form_sql.bat index 84f89fb0..f272c367 100644 --- a/documentation/3.1.0/dockerized/scripts/windows/create_default_form_sql.bat +++ b/documentation/3.1.0/dockerized/scripts/windows/create_default_form_sql.bat @@ -1,64 +1,60 @@ @echo off setlocal -:: Exit on error -setlocal EnableDelayedExpansion - :: Define the GitHub raw URL for the JSON file set "GITHUB_REPO=https://raw.githubusercontent.com/ELEVATE-Project/mentoring-mobile-app/refs/heads/release-3.1.1/forms.json" set "JSON_FILE=forms.json" -:: set organization_id +:: Set organization_id set "organization_id=1" - -:: Check if the output directory is passed as an argument, otherwise use the current directory +:: Check if output directory is provided as an argument if "%~2"=="" ( set "OUTPUT_DIR=." ) else ( set "OUTPUT_DIR=%~2" ) -:: Ensure the directory exists -if not exist "!OUTPUT_DIR!" ( - echo Error: Directory '!OUTPUT_DIR!' does not exist. +:: Ensure the output directory exists +if not exist "%OUTPUT_DIR%" ( + echo Error: Directory '%OUTPUT_DIR%' does not exist. exit /b 1 ) -:: Define the output file path in the specified directory -set "SQL_OUTPUT_FILE=!OUTPUT_DIR!\forms.sql" +:: Define output file path for the SQL file +set "SQL_OUTPUT_FILE=%OUTPUT_DIR%\forms.sql" -:: Fetch the JSON file from the GitHub repository +:: Fetch JSON file from GitHub repository echo Fetching JSON file from GitHub... -curl -o "!JSON_FILE!" "!GITHUB_REPO!" +curl -o "%JSON_FILE%" "%GITHUB_REPO%" -:: Check if the download was successful +:: Check if download was successful if errorlevel 1 ( echo Failed to download JSON file from GitHub. exit /b 1 ) -:: Append 'SELECT NULL;' to the end of the SQL file -echo delete from forms; > "!SQL_OUTPUT_FILE!" - -:: Create or overwrite the SQL output file +:: Write initial SQL delete statement to clear existing data in 'forms' table +echo delete from forms; > "%SQL_OUTPUT_FILE%" echo Generating SQL insert statements... ->> "!SQL_OUTPUT_FILE!" ( - echo. - - :: Initialize ID counter starting from 1 - set /a id_counter=1 - - :: Use PowerShell to parse JSON and generate SQL - for /f "usebackq delims=" %%i in (`powershell -command "Get-Content '!JSON_FILE!' | ConvertFrom-Json | ForEach-Object { 'INSERT INTO forms (id, type, sub_type, data, version, organization_id) VALUES (' + [int]$env:id_counter + ', ''$($_.type)'', ''$($_.sub_type)'', ''$($_.data | ConvertTo-Json -Compress -Depth 100)'', 1, ''!organization_id!'');' }"`) do ( - echo %%i - set /a id_counter+=1 - ) -) - -:: Append 'SELECT NULL;' to the end of the SQL file -echo SELECT NULL; >> "!SQL_OUTPUT_FILE!" - -echo SQL file generated: "!SQL_OUTPUT_FILE!" +:: Initialize ID counter +set /a id_counter=1 + +:: Use PowerShell to parse JSON and generate a separate SQL insert statement for each object +powershell -Command ^ + "$jsonData = Get-Content '%JSON_FILE%' | ConvertFrom-Json; " ^ + "$id_counter = 1; " ^ + "$jsonData | ForEach-Object { " ^ + "$current_timestamp = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); " ^ + "$sql = 'INSERT INTO forms (id, type, sub_type, data, version, organization_id, created_at, updated_at) VALUES (' + $id_counter.ToString() + ', ''' + $_.type + ''', ''' + $_.sub_type + ''', ''';" ^ + "$sql += ($_.data | ConvertTo-Json -Compress -Depth 100).Replace(\"'\", \"''\") + ''', 1, %organization_id%, ''' + $current_timestamp + ''', ''' + $current_timestamp + ''');'; " ^ + "Add-Content -Path '%SQL_OUTPUT_FILE%' -Value $sql; " ^ + "$id_counter += 1; " ^ + "}" + +:: Append a final statement to the SQL file +echo SELECT NULL; >> "%SQL_OUTPUT_FILE%" + +echo SQL file generated: "%SQL_OUTPUT_FILE%" endlocal diff --git a/documentation/3.1.0/dockerized/scripts/windows/insert_sample_forms.bat b/documentation/3.1.0/dockerized/scripts/windows/insert_sample_forms.bat index 4652fab5..7e3f9ffe 100644 --- a/documentation/3.1.0/dockerized/scripts/windows/insert_sample_forms.bat +++ b/documentation/3.1.0/dockerized/scripts/windows/insert_sample_forms.bat @@ -1,107 +1,139 @@ @echo off setlocal enabledelayedexpansion -REM Exit on error -set "ERRORLEVEL=0" - -REM Ensure correct number of arguments are provided +:: Ensure the correct number of arguments are provided if "%~2"=="" ( - echo Error: Folder name and database URL not provided. Usage: %0 + echo Error: Folder name and database URL not provided. Usage: %0 <folder_name> <database_url> exit /b 1 ) -REM Use the provided folder name +:: Use the provided folder name set "FOLDER_NAME=sample-data\%~1" -REM Check if folder exists -if not exist "!FOLDER_NAME!" ( - echo Error: Folder '!FOLDER_NAME!' not found. +:: Check if folder exists +if not exist "%FOLDER_NAME%" ( + echo Error: Folder '%FOLDER_NAME%' not found. exit /b 1 ) -REM Use the provided database URL +:: Use the provided database URL set "DEV_DATABASE_URL=%~2" -REM Extract database credentials and connection details using for -for /f "tokens=4,5,6,7 delims=:@/" %%a in ("%DEV_DATABASE_URL%") do ( - set "DB_USER=%%a" - set "DB_PASSWORD=%%b" - set "DB_HOST=%%c" - set "DB_PORT=%%d" -) +set "conn=%DEV_DATABASE_URL%" -REM Extract DB_NAME -for /f "tokens=*" %%a in ("%DEV_DATABASE_URL%") do ( - for /f "delims=/ tokens=2" %%b in ("%%a") do set "DB_NAME=%%b" -) +set "conn=!conn:postgres://=!" + +for /f "tokens=1 delims=:" %%a in ("!conn!") do set "DB_USER=%%a" + +set "conn=!conn:%DB_USER%:=!" + +for /f "tokens=1 delims=@" %%a in ("!conn!") do set "DB_PASSWORD=%%a" + +set "conn=!conn:%DB_PASSWORD%@=!" + +set "hostport=!conn:*@=!" +for /f "tokens=1 delims=:" %%a in ("!hostport!") do set "DB_HOST=%%a" -REM Log database variables -echo Extracted Database Variables: -echo DB_USER: !DB_USER! -echo DB_PASSWORD: !DB_PASSWORD! -echo DB_HOST: !DB_HOST! -echo DB_PORT: !DB_PORT! -echo DB_NAME: !DB_NAME! - -REM Define the container name (same as DB_HOST) -set "CONTAINER_NAME=!DB_HOST!" - -REM Wait for Docker container to be up -echo Waiting for Docker container '!CONTAINER_NAME!' to be up... -:waitForContainer -docker inspect "!CONTAINER_NAME!" >nul 2>&1 +set "conn=!conn:%DB_HOST%:=!" + +for /f "tokens=1 delims=/" %%a in ("!conn!") do set "DB_PORT=%%a" + +set "conn=!conn:*%DB_PORT%/=!" + +set "DB_NAME=!conn!" + +echo DB_USER: %DB_USER% +echo DB_PASSWORD: %DB_PASSWORD% +echo DB_HOST: %DB_HOST% +echo DB_PORT: %DB_PORT% +echo DB_NAME: %DB_NAME% + +:: Define the container name (same as DB_HOST) +set "CONTAINER_NAME=%DB_HOST%" + +:: Wait for Docker container to be up +echo Waiting for Docker container '%CONTAINER_NAME%' to be up... +:WAIT_CONTAINER +docker inspect "%CONTAINER_NAME%" >nul 2>&1 if errorlevel 1 ( echo Waiting for container... - timeout /t 1 >nul - goto waitForContainer + timeout /t 1 /nobreak + goto WAIT_CONTAINER ) echo Container is now up. -REM Wait for PostgreSQL to be ready to accept connections -echo Waiting for PostgreSQL on '!DB_HOST!:!DB_PORT!' to accept connections... -:waitForDB -docker exec "!CONTAINER_NAME!" pg_isready -h localhost -p !DB_PORT! -U !DB_USER! >nul 2>&1 +:: Wait for PostgreSQL to be ready to accept connections +echo Waiting for PostgreSQL on '%DB_HOST%:%DB_PORT%' to accept connections... +:WAIT_DB +docker exec "%CONTAINER_NAME%" bash -c "pg_isready -h localhost -p %DB_PORT% -U %DB_USER%" >nul 2>&1 if errorlevel 1 ( echo Waiting for database to be ready... - timeout /t 1 >nul - goto waitForDB + timeout /t 1 /nobreak + goto WAIT_DB ) echo Database is ready. -REM Function to check if the database exists -:checkDatabase -docker exec "!CONTAINER_NAME!" psql -h localhost -U !DB_USER! -p !DB_PORT! -lqt | findstr /i /c:"!DB_NAME!" >nul -exit /b %errorlevel% - -echo Checking existence of database '!DB_NAME!'... -:waitForDBExistence -call :checkDatabase +:: Check if the database exists +:CHECK_DB +docker exec "%CONTAINER_NAME%" bash -c "PGPASSWORD='%DB_PASSWORD%' psql -h localhost -U %DB_USER% -p %DB_PORT% -lqt | cut -d \| -f 1 | grep -qw '%DB_NAME%'" >nul 2>&1 if errorlevel 1 ( - echo Database '!DB_NAME!' does not exist, waiting... - timeout /t 5 >nul - goto waitForDBExistence + echo Database '%DB_NAME%' does not exist, waiting... + timeout /t 5 /nobreak + goto CHECK_DB ) -echo Database '!DB_NAME!' exists, proceeding with script. +echo Database '%DB_NAME%' exists, proceeding with script. -REM ------------------------------------------------------------ -REM New code to push `forms.sql` data into the database -REM ------------------------------------------------------------ +:: Retrieve and prepare SQL file operations +set "SAMPLE_COLUMNS_FILE=%FOLDER_NAME%\sampleData.sql" +if not exist "%SAMPLE_COLUMNS_FILE%" ( + echo Error: sampleData.sql not found in folder '%FOLDER_NAME%'. + exit /b 1 +) -set "DEFAULT_FORM_FOLDER_LOCATION=!FOLDER_NAME!" +:: Copy the SQL file into the Docker container +echo Copying sampleData.sql to container '%CONTAINER_NAME%'... +docker cp "%SAMPLE_COLUMNS_FILE%" "%CONTAINER_NAME%:/sampleData.sql" -REM Ensure create_default_form_sql.bat is executable -call create_default_form_sql.bat "!FOLDER_NAME!" +:: Execute the SQL file inside the container +echo Executing sampleData.sql in the database... +docker exec "%CONTAINER_NAME%" bash -c "PGPASSWORD='%DB_PASSWORD%' psql -h localhost -U %DB_USER% -d %DB_NAME% -p %DB_PORT% -f /sampleData.sql" +if errorlevel 1 ( + echo Error executing SQL script. + exit /b 1 +) else ( + echo SQL script executed successfully. +) + +echo Sample Data Insertion Completed +:: New code to push `forms.sql` data into the database +set "DEFAULT_ORG_ID=%~1" set "FORMS_SQL_FILE=forms.sql" -if not exist "!FORMS_SQL_FILE!" ( - echo Error: forms.sql not found. + + +:: Check if the create_default_form_sql.sh script exists +if not exist "create_default_form_sql.bat" ( + echo Error: create_default_form_sql.bat not found. exit /b 1 ) -echo Copying forms.sql to container '!CONTAINER_NAME!'... -docker cp "!FORMS_SQL_FILE!" "!CONTAINER_NAME!:/forms.sql" +:: Run the create_default_form_sql.sh script with the provided arguments +echo Running create_default_form_sql.bat... +bash create_default_form_sql.bat "%ORGANIZATION_ID%" "%FOLDER_NAME%" + +if errorlevel 1 ( + echo Error running create_default_form_sql.bat. + exit /b 1 +) else ( + echo create_default_form_sql.bat executed successfully. +) + +echo Copying forms.sql to container '%CONTAINER_NAME%'... +docker cp "%FORMS_SQL_FILE%" "%CONTAINER_NAME%:/forms.sql" echo Inserting Forms Data from forms.sql... -docker exec --user "!DB_USER!" "!CONTAINER_NAME!" psql -h localhost -U !DB_USER! -d !DB_NAME! -p !DB_PORT! -f /forms.sql +docker exec --user "%DB_USER%" "%CONTAINER_NAME%" bash -c "PGPASSWORD='%DB_PASSWORD%' psql -h localhost -U %DB_USER% -d %DB_NAME% -p %DB_PORT% -f /forms.sql" echo Forms Data Insertion Completed + +endlocal