-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* onboarding state implementation * tests migrations * added onboarding state * changed comment * added subsidiary state to onboarding state * changed script to add subsidiary state and fixed some bug --------- Co-authored-by: Ashutosh619-sudo <[email protected]> Co-authored-by: Nilesh Pant <[email protected]>
- Loading branch information
1 parent
2f5f4e0
commit aa7c231
Showing
6 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
apps/workspaces/migrations/0033_workspace_onboarding_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.1.14 on 2023-10-10 11:39 | ||
|
||
import apps.workspaces.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('workspaces', '0032_configuration_name_in_journal_entry'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='workspace', | ||
name='onboarding_state', | ||
field=models.CharField(choices=[('CONNECTION', 'CONNECTION'), ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), ('ADVANCED_CONFIGURATION', 'ADVANCED_CONFIGURATION'), ('COMPLETE', 'COMPLETE')], default=apps.workspaces.models.get_default_onboarding_state, help_text='Onboarding status of the workspace', max_length=50, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.1.14 on 2023-10-12 07:50 | ||
|
||
import apps.workspaces.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('workspaces', '0033_workspace_onboarding_state'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='workspace', | ||
name='onboarding_state', | ||
field=models.CharField(choices=[('CONNECTION', 'CONNECTION'), ('SUBSIDIARY', 'SUBSIDIARY'), ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), ('ADVANCED_CONFIGURATION', 'ADVANCED_CONFIGURATION'), ('COMPLETE', 'COMPLETE')], default=apps.workspaces.models.get_default_onboarding_state, help_text='Onboarding status of the workspace', max_length=50, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
-- Create a view for joined on all settings tables to figure out onboarding progress | ||
create or replace view all_settings_view as | ||
select | ||
w.id as workspace_id, | ||
wgs.id as configuration_id, | ||
gm.id as general_mappings_id, | ||
qc.id as netsuite_creds_id, | ||
sm.id as subsidiary_id | ||
from workspaces w | ||
left join | ||
configurations wgs on w.id = wgs.workspace_id | ||
left join | ||
netsuite_credentials nc on qc.workspace_id = w.id | ||
left join | ||
general_mappings gm on gm.workspace_id = w.id | ||
left join | ||
subsidiary_mappings sm on sm.workspace_id = w.id | ||
where w.onboarding_state = 'CONNECTION'; | ||
|
||
begin; -- Start Transaction Block | ||
|
||
-- Count of all workspaces where netsuite are present, configuration is present and general mappings are present | ||
select | ||
'NC=TRUE, C=TRUE, GM=TRUE, SM=True' as setting, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null and subsidiary_id is not null; | ||
|
||
--- Update all of the above to have onboarding state set to 'COMPLETE' | ||
update workspaces | ||
set | ||
onboarding_state = 'COMPLETE' | ||
where id in ( | ||
select | ||
workspace_id | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null and subsidiary_id is not null | ||
); | ||
|
||
-- Count of all workspaces where netsuite cred is present and general mapping and credentials and subsidiary are not present. | ||
select | ||
'NC=TRUE, C=FALSE, GM=FALSE, SM=FALSE' as setting, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is null; | ||
|
||
-- Update all of the above to have onboarding state set to 'SUBSIDIARY' | ||
update workspaces | ||
set | ||
onboarding_state = 'SUBSIDIARY' | ||
where id in ( | ||
select | ||
workspace_id | ||
from all_settings_view | ||
where | ||
configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is null | ||
); | ||
|
||
-- Count of all workspaces where netsuite cred and subsidiary are present, configuration is not present and general mappings are not present | ||
select | ||
'NC=TRUE, C=FALSE, GM=FALSE, SM=TRUE' as settings, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null; | ||
|
||
--- Update all of the above to have onboarding state set to 'MAP_EMPLOYEES' | ||
update workspaces | ||
set | ||
onboarding_state = 'MAP_EMPLOYEES' | ||
where id in ( | ||
select | ||
workspace_id | ||
from all_settings_view | ||
where | ||
configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null | ||
); | ||
|
||
|
||
-- Count of all workspaces where netsuite are present, configuration is present, subsidiary is present and general mappings are not present | ||
select | ||
'NC=TRUE, C=TRUE, GM=FALSE, SM=TRUE' as settings, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null; | ||
|
||
--- Update all of the above to have onboarding state set to 'EXPORT_SETTINGS' | ||
update workspaces | ||
set | ||
onboarding_state = 'EXPORT_SETTINGS' | ||
where id in ( | ||
select | ||
workspace_id | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters