Skip to content

Commit

Permalink
feat: rename demo toggles (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: jianggang <jianggang@didiglobal.com>
  • Loading branch information
gangb-tech and jianggang authored Aug 23, 2022
1 parent b792530 commit 077c325
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 23 deletions.
47 changes: 24 additions & 23 deletions src/main/java/com/featureprobe/api/service/GuestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public class GuestService {
private static final String[] toggleSql= {"INSERT INTO `toggle` (`organization_id`, `name`, `key`, " +
"`description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, " +
"`client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) " +
"VALUES (${organization_id}, 'feature toggle01', 'feature_toggle01', '', 'boolean', 0, " +
"VALUES (${organization_id}, 'Campaign Enable', 'campaign_enable', '', 'boolean', 0, " +
"'[{\\\"value\\\":\\\"false\\\", \\\"name\\\":\\\"disabled\\\"," +
"\\\"description\\\":\\\"\\\"},{\\\"value\\\":" +
"\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]', " +
"'${project_key}', 0, 1, 0, ${user_id}, ${user_id}, now(), now())",

"INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " +
"`disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, " +
"`modified_time`) VALUES (${organization_id}, 'feature_toggle01', 'online', '${project_key}', " +
"`modified_time`) VALUES (${organization_id}, 'campaign_enable', 'online', '${project_key}', " +
"1, 1, '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0},\\\"defaultServe\\\":" +
"{\\\"select\\\":1},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":" +
"\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," +
Expand All @@ -61,16 +61,16 @@ public class GuestService {

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle01', 'online', 1, 'true', 1, 'enabled')",
"'campaign_enable', 'online', 1, 'true', 1, 'enabled')",

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle01', 'online', 1, 'false', 0, 'disabled')",
"'campaign_enable', 'online', 1, 'false', 0, 'disabled')",

"INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " +
"`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " +
"`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " +
"'feature_toggle01', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," +
"'campaign_enable', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," +
"\\\"defaultServe\\\":{\\\"select\\\":1},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\"," +
"\\\"name\\\":\\\"disabled\\\",\\\"description\\\":\\\"\\\"}," +
"{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"" +
Expand All @@ -79,15 +79,15 @@ public class GuestService {

"INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " +
"`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle02', " +
"'feature_toggle02', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"" +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'Campaign Allow List', " +
"'campaign_allow_list', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"" +
"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":" +
"\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]', '${project_key}', " +
"0, 1, 0, ${user_id}, ${user_id}, now(), now())",

"INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " +
"`disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) " +
"VALUES (${organization_id}, 'feature_toggle02', 'online', '${project_key}', 1, 0, " +
"VALUES (${organization_id}, 'campaign_allow_list', 'online', '${project_key}', 1, 0, " +
"'{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," +
"\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," +
Expand All @@ -100,16 +100,16 @@ public class GuestService {

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle02', 'online', 1, 'true', 1, 'enabled')",
"'campaign_allow_list', 'online', 1, 'true', 1, 'enabled')",

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle02', 'online', 1, 'false', 0, 'disabled')",
"'campaign_allow_list', 'online', 1, 'false', 0, 'disabled')",

"INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " +
"`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " +
"`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " +
"'feature_toggle02', '', '{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"'campaign_allow_list', '', '{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," +
"\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," +
"\\\"numberType\\\":false,\\\"datetimeType\\\":false,\\\"semVerType\\\":false}]," +
Expand All @@ -122,14 +122,15 @@ public class GuestService {

"INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " +
"`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle03', " +
"'feature_toggle03', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"disabled\\\"," +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, " +
"'Campaign Percentage Rollout', 'campaign_percentage_rollout', '', 'boolean', 0, " +
"'[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"disabled\\\"," +
"\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"enabled\\\"," +
"\\\"description\\\":\\\"\\\"}]', '${project_key}', 0, 1, 0, ${user_id}, ${user_id}, now(), now())",

"INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " +
"`disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) " +
"VALUES (${organization_id}, 'feature_toggle03', 'online', '${project_key}', 1, 0, " +
"VALUES (${organization_id}, 'campaign_percentage_rollout', 'online', '${project_key}', 1, 0, " +
"'{\\\"rules\\\":[], \\\"disabledServe\\\":{\\\"select\\\":0},\\\"defaultServe\\\":" +
"{\\\"split\\\":[6000,4000]}, \\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":" +
"\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," +
Expand All @@ -138,32 +139,32 @@ public class GuestService {

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle03', 'online', 1, 'true', 1, 'enabled')",
"'campaign_percentage_rollout', 'online', 1, 'true', 1, 'enabled')",

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle03', 'online', 1, 'false', 0, 'disabled')",
"'campaign_percentage_rollout', 'online', 1, 'false', 0, 'disabled')",

"INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " +
"`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " +
"`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " +
"'feature_toggle03', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," +
"'campaign_percentage_rollout', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," +
"\\\"defaultServe\\\":{\\\"split\\\":[8000,2000]},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\"," +
"\\\"name\\\":\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\"" +
":\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]}', 0, " +
"1, 0, now(), ${user_id}, now(), ${user_id})",

"INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " +
"`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle04', " +
"'feature_toggle04', '', 'number', 1, '[{\\\"value\\\":\\\"10\\\",\\\"name\\\":\\\"$10\\\"," +
"`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'Promotion Campaign', " +
"'promotion_campaign', '', 'number', 1, '[{\\\"value\\\":\\\"10\\\",\\\"name\\\":\\\"$10\\\"," +
"\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"20\\\",\\\"name\\\":\\\"$20\\\"," +
"\\\"description\\\":\\\"\\\"}]', '${project_key}', 0, 1, 0, ${user_id}, " +
"${user_id}, now(), now())",

"INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " +
"`disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) " +
"VALUES (${organization_id}, 'feature_toggle04', 'online', '${project_key}', 1, 0, " +
"VALUES (${organization_id}, 'promotion_campaign', 'online', '${project_key}', 1, 0, " +
"'{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," +
"\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," +
Expand All @@ -181,16 +182,16 @@ public class GuestService {

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " +
"'feature_toggle04', 'online', 1, '20', 1, '$20')",
"'promotion_campaign', 'online', 1, '20', 1, '$20')",

"INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " +
"`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, " +
"'${project_key}', 'feature_toggle04', 'online', 1, '10', 0, '$10')",
"'${project_key}', 'promotion_campaign', 'online', 1, '10', 0, '$10')",

"INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " +
"`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " +
"`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " +
"'feature_toggle04', '', '{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"'promotion_campaign', '', '{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," +
"\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\",\\\"objects\\\":[\\\"00001\\\"," +
"\\\"00002\\\"],\\\"segmentType\\\":false,\\\"numberType\\\":false,\\\"datetimeType\\\":false," +
"\\\"semVerType\\\":false}],\\\"name\\\":\\\"\\\"," +
Expand Down
75 changes: 75 additions & 0 deletions src/main/resources/db/migration/V24__update_remote_url_toggle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
UPDATE `toggle`
SET name = 'Campaign Enable',
`key` = 'campaign_enable'
WHERE `key` = 'feature_toggle01';

UPDATE `targeting`
SET toggle_key = 'campaign_enable'
WHERE toggle_key = 'feature_toggle01';

UPDATE `variation_history`
SET toggle_key = 'campaign_enable'
WHERE toggle_key = 'feature_toggle01';

UPDATE `targeting_version`
SET toggle_key = 'campaign_enable'
WHERE toggle_key = 'feature_toggle01';


UPDATE `toggle`
SET name = 'Campaign Allow List',
`key` = 'campaign_allow_list'
WHERE `key` = 'feature_toggle02';

UPDATE `targeting`
SET toggle_key = 'campaign_allow_list'
WHERE toggle_key = 'feature_toggle02';

UPDATE `variation_history`
SET toggle_key = 'campaign_allow_list'
WHERE toggle_key = 'feature_toggle02';

UPDATE `targeting_version`
SET toggle_key = 'campaign_allow_list'
WHERE toggle_key = 'feature_toggle02';


UPDATE `toggle`
SET name = 'Campaign Percentage Rollout',
`key` = 'campaign_percentage_rollout'
WHERE `key` = 'feature_toggle03';

UPDATE `targeting`
SET toggle_key = 'campaign_percentage_rollout'
WHERE toggle_key = 'feature_toggle03';

UPDATE `variation_history`
SET toggle_key = 'campaign_percentage_rollout'
WHERE toggle_key = 'feature_toggle03';

UPDATE `targeting_version`
SET toggle_key = 'campaign_percentage_rollout'
WHERE toggle_key = 'feature_toggle03';


UPDATE `toggle`
SET name = 'Promotion Campaign',
`key` = 'promotion_campaign'
WHERE `key` = 'feature_toggle04';

UPDATE `targeting`
SET toggle_key = 'promotion_campaign'
WHERE toggle_key = 'feature_toggle04';

UPDATE `variation_history`
SET toggle_key = 'promotion_campaign'
WHERE toggle_key = 'feature_toggle04';

UPDATE `targeting_version`
SET toggle_key = 'promotion_campaign'
WHERE toggle_key = 'feature_toggle04';


UPDATE `targeting`
SET content = '{\"rules\":[],\"disabledServe\":{\"select\":1},\"defaultServe\":{\"select\":1},\"variations\":[{\"value\":\"https://featureprobe.io/server\",\"name\":\"online service\",\"description\":\"\"},{\"value\":\"http://127.0.0.1:4007\",\"name\":\"local docker\",\"description\":\"\"}]}'
WHERE toggle_key = 'remote_url' AND organization_id = -1;

0 comments on commit 077c325

Please sign in to comment.