Skip to content

Commit

Permalink
Fix codes
Browse files Browse the repository at this point in the history
  • Loading branch information
toru-takahashi committed Aug 8, 2024
1 parent 8fb4029 commit 59bd265
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion activation_actions/incremental_wf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This example code considers `add` (new profiles) and `delete` (dropped profiles)

1. Download this folder into your local.
2. Upload the workflow `td wf push incremental_wf` (Require td command installation)
3. Set `incremental_wf` as a custom workflow of the Activation Action in Audience Studio.
3. Change key_column field in incremental_wf.dig depending on your required watermark. (Default: td_client_id)
4. Set `incremental_wf` as a custom workflow of the Activation Action in Audience Studio.

## Available Parameters for Activation Actions

Expand Down
12 changes: 6 additions & 6 deletions activation_actions/incremental_wf/calc_diff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ SELECT * FROM (
'${session_id}' as session_id,
'${attempt_id}' as attempt_id,
CASE
WHEN h.profile_id IS NULL THEN 'add'
WHEN a.profile_id IS NULL THEN 'delete'
ELSE '???' -- no change or modified
WHEN h.${key_column} IS NULL THEN 'add'
WHEN a.${key_column} IS NULL THEN 'delete'
ELSE 'modified' -- no change or modified
END as change
, coalesce(h.profile_id, a.profile_id) as profile_id
, coalesce(h.${key_column}, a.${key_column}) as ${key_column}
FROM
previous_profiles h
FULL OUTER JOIN ${activation_actions_table} a
ON h.profile_id = a.profile_id
ON h.${key_column} = a.${key_column}
)
WHERE
change != '???'
change != 'modified'
15 changes: 12 additions & 3 deletions activation_actions/incremental_wf/incremental_wf.dig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
_export:
td:
database: '${activation_actions_db}'
key_column: 'td_client_id' # Pleaes update your key id for diff

# tables:
# - 'previous_profiles': table that contains the profiles of the previous run
Expand All @@ -16,6 +17,14 @@ _export:
td_ddl>:
empty_tables: ['diff']

+preparation_schema_previous_profiles:
td>:
query: "ALTER TABLE IF EXISTS previous_profiles ADD COLUMN IF NOT EXISTS ${key_column} varchar; ALTER TABLE IF EXISTS previous_profiles ADD COLUMN IF NOT EXISTS change varchar;"

+preparation_schema_diff:
td>:
query: "ALTER TABLE IF EXISTS diff ADD COLUMN IF NOT EXISTS ${key_column} varchar; ALTER TABLE IF EXISTS diff ADD COLUMN IF NOT EXISTS change varchar;"

+calc_diff:
td>: calc_diff.sql

Expand All @@ -25,14 +34,14 @@ _export:

+activation_for_added_profiles:
td>:
query: "SELECT * FROM ${activation_actions_table} WHERE profile_id in (SELECT profile_id FROM diff WHERE change = 'add')"
query: "SELECT * FROM ${activation_actions_table} WHERE ${key_column} in (SELECT ${key_column} FROM diff WHERE change = 'add')"
# result_connection: 'authentication-1'
# result_settings: 'authentication-1-setting-1'
# Enable above if you want to activate to the setting 1

+activation_for_deleted_profiles:
td>:
query: "SELECT * FROM previous_profiles WHERE profile_id in (SELECT profile_id FROM diff WHERE change = 'delete')"
query: "SELECT * FROM previous_profiles WHERE ${key_column} in (SELECT ${key_column} FROM diff WHERE change = 'delete')"
# result_connection: 'authentication-2'
# result_settings: 'authentication-2-setting-1'
# Enable above if you want to activate to the setting 2
Expand All @@ -47,5 +56,5 @@ _export:

+insert_profiles_into_history:
td>:
query: "SELECT '${session_id}' as session_id, '${attempt_id}' as attempt_id, * FROM ${activation_actions_table} ;"
query: "SELECT '${session_id}' as session_id, '${attempt_id}' as attempt_id, * FROM ${activation_actions_table};"
create_table: 'previous_profiles'
2 changes: 1 addition & 1 deletion activation_actions/restrict_and_add_column/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This sample code restricts the profiles output by using a filter in Custom Workf
### How to use

1. Download this folder into your local.
2. Upload the workflow `td wf push restrict_and_add_column` (Require td command installation)
2. Upload the workflow `td wf push restrict_and_add_column` (Require td command installation). Default: Email is defined as exported field.
3. Set `restrict_and_add_column` as a custom workflow of the Activation Action in Audience Studio.

## Available Parameters for Activation Actions
Expand Down

0 comments on commit 59bd265

Please sign in to comment.