-
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.
- Loading branch information
Ashutosh619-sudo
committed
Oct 11, 2023
1 parent
74ec664
commit 5c31b3f
Showing
3 changed files
with
148 additions
and
0 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
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,115 @@ | ||
-- 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 | ||
from workspaces w | ||
left join | ||
configurations wgs on w.id = wgs.workspace_id | ||
left join | ||
netsuite_credentials qc on qc.workspace_id = w.id | ||
left join | ||
general_mappings gm on gm.workspace_id = w.id | ||
where w.onboarding_state = 'CONNECTION'; | ||
|
||
begin; -- Start Transaction Block | ||
|
||
-- Count of all workspaces where qbo creds are present, configuration is present and general mappings are present | ||
select | ||
'QC=TRUE, C=TRUE, GM=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; | ||
|
||
--- 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 | ||
); | ||
|
||
-- Count of all workspaces where qbo creds are present, configuration is present and general mappings are not present | ||
select | ||
'QC=TRUE, C=TRUE, GM=FALSE' 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; | ||
|
||
--- 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 not null and netsuite_creds_id is not null | ||
); | ||
|
||
|
||
-- Count of all workspaces where qbo creds are present, configuration is not present and general mappings are not present | ||
select | ||
'QC=TRUE, C=FALSE, GM=FALSE' 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; | ||
|
||
--- 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 not null and netsuite_creds_id is not null | ||
); | ||
|
||
|
||
-- Count of all workspaces where qbo creds is not present, configuration is present and general mappings is present | ||
select | ||
'QC=FALSE, C=TRUE, GM=TRUE' as settings, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is 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 null | ||
); | ||
|
||
|
||
-- Count of all workspaces where qbo creds are not present, configuration is present and general mappings are not present | ||
select | ||
'QC=FALSE, C=TRUE, GM=FALSE' as settings, count(*) | ||
from all_settings_view | ||
where | ||
configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is 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 null | ||
); |