Skip to content

Commit aef1519

Browse files
author
MDias
committed
Implementing push refactor
1 parent 51b1a5d commit aef1519

5 files changed

+28
-64
lines changed

Diff for: push_messaging_cadence.view.lkml

+1-33
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
# Push Messaging Cadence
22
view: push_messaging_cadence {
3-
derived_table: {
4-
sql: select to_timestamp(sends.time) as send_timestamp,
5-
sends.user_id as send_user_id,
6-
bounces.user_id as bounce_user_id,
7-
sends.message_variation_id as s_message_variation_id,
8-
sends.canvas_step_id as s_canvas_step_id,
9-
sends.campaign_name as s_campaign_name,
10-
sends.canvas_name as s_canvas_name,
11-
sends.platform as s_platform,
12-
sends.id as send_id,
13-
opens.id as open_id,
14-
bounces.id as bounce_id,
15-
rank() over (partition by send_user_id order by send_timestamp asc) as send_event,
16-
iff(timediff(second, send_timestamp, to_timestamp(opens.time))=min(timediff(second, send_timestamp, to_timestamp(opens.time))) over (partition by open_id), true, false) as min_open_difference,
17-
iff(timediff(second, send_timestamp, to_timestamp(bounces.time))=min(timediff(second, send_timestamp, to_timestamp(bounces.time))) over (partition by bounce_id), true, false) as min_bounce_difference,
18-
min(send_timestamp) over (partition by send_user_id order by send_timestamp asc) as first_sent,
19-
datediff(day, lag(send_timestamp) over (partition by send_user_id order by send_timestamp asc), send_timestamp) as diff_days,
20-
datediff(week, lag(send_timestamp) over (partition by send_user_id order by send_timestamp asc), send_timestamp) as diff_weeks
21-
FROM PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_SEND AS sends
22-
LEFT JOIN PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_OPEN AS opens ON (sends.user_id)=(opens.user_id)
23-
AND
24-
(sends.device_id)=(opens.device_id)
25-
AND
26-
((sends.message_variation_id)=(opens.message_variation_id)
27-
OR
28-
(sends.canvas_step_id)=(opens.canvas_step_id))
29-
LEFT JOIN PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_BOUNCE AS bounces ON (sends.user_id)=(bounces.user_id)
30-
AND
31-
(sends.device_id)=(bounces.device_id)
32-
AND
33-
((sends.message_variation_id)=(bounces.message_variation_id)
34-
OR
35-
(sends.canvas_step_id)=(bounces.canvas_step_id)) ;;
3+
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.TBL_BRAZE_PUSH_CADENCE ;;
364
}
375

386
dimension_group: send {

Diff for: push_messaging_frequency.view.lkml

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
# Push Messaging Frequency
22
view: push_messaging_frequency {
33
derived_table: {
4-
sql: SELECT * FROM
5-
(select distinct
6-
sends.user_id as sent_user_id,
7-
date_trunc({% parameter date_granularity %}, to_timestamp(sends.time)) as sent_time,
8-
opens.id as opened_id,
9-
coalesce(count(distinct sends.id) over (partition by sent_user_id, sent_time),0)-coalesce(count(distinct bounces.id) over (partition by sent_user_id, sent_time),0) as frequency,
10-
row_number() over (partition by sent_user_id, sent_time order by sent_time) as rank
11-
FROM PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_SEND as sends
12-
LEFT JOIN PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_BOUNCE as bounces ON (sends.user_id)=(bounces.user_id)
13-
AND
14-
((sends.message_variation_id)=(bounces.message_variation_id)
15-
OR
16-
(sends.canvas_step_id)=(bounces.canvas_step_id))
17-
LEFT JOIN PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_OPEN as opens ON (sends.user_id)=(opens.user_id)
18-
AND
19-
((sends.message_variation_id)=(opens.message_variation_id)
20-
OR
21-
(sends.canvas_step_id)=(opens.canvas_step_id))
22-
WHERE
23-
{% condition campaign_name %} sends.campaign_name {% endcondition %}
24-
AND
25-
{% condition canvas_name %} sends.canvas_name {% endcondition %}
26-
AND
27-
{% condition message_variation_id %} sends.message_variation_id {% endcondition %}
28-
AND
29-
{% condition canvas_name %} sends.canvas_step_id {% endcondition %}
30-
AND
31-
{% condition platform %} sends.platform {% endcondition %}) WHERE frequency > 0
4+
sql: SELECT * FROM (
5+
SELECT
6+
sent_user_id,
7+
date_trunc({% parameter date_granularity %}, to_timestamp(sent_time)) as sent_time,
8+
opened_id,
9+
frequency,
10+
rank,
11+
campaign_name,
12+
canvas_name,
13+
message_variation_id,
14+
canvas_step_id,
15+
platform
16+
FROM PROD_ANALYTICS.ANALYTICS_PROCESSED.TBL_BRAZE_PUSH_FREQUENCY
17+
WHERE
18+
{% condition campaign_name %} campaign_name {% endcondition %}
19+
AND
20+
{% condition canvas_name %} canvas_name {% endcondition %}
21+
AND
22+
{% condition message_variation_id %} message_variation_id {% endcondition %}
23+
AND
24+
{% condition canvas_name %} canvas_step_id {% endcondition %}
25+
AND
26+
{% condition platform %} platform {% endcondition %}
27+
) WHERE frequency > 0
3228
;;
3329
}
3430

Diff for: users_messages_pushnotification_bounce.view.lkml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Push Bounce Events
22
view: users_messages_pushnotification_bounce {
3-
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_BOUNCE ;;
3+
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.TBL_BRAZE_PUSH_BOUNCES ;;
44

55
dimension: id {
66
primary_key: yes

Diff for: users_messages_pushnotification_open.view.lkml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Push Open Events
22
view: users_messages_pushnotification_open {
3-
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_OPEN ;;
3+
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.TBL_BRAZE_PUSH_OPENS ;;
44

55
dimension: id {
66
primary_key: yes

Diff for: users_messages_pushnotification_send.view.lkml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Push Send Events
22
view: users_messages_pushnotification_send {
3-
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.VW_MP_BRAZE_PUSH_NOTIFICATION_SEND ;;
3+
sql_table_name: PROD_ANALYTICS.ANALYTICS_PROCESSED.TBL_BRAZE_PUSH_SENDS ;;
44

55
dimension: id {
66
primary_key: yes

0 commit comments

Comments
 (0)