-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathq_goal_achieved_meta_data.view.lkml
executable file
·140 lines (126 loc) · 3.74 KB
/
q_goal_achieved_meta_data.view.lkml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
view: q_goal_achieved_meta_data {
derived_table: {
sql:
WITH
iterations AS
(
SELECT
experienceId AS experienceId,
variationMasterId AS variationMasterId,
iterationId AS iterationId,
MAX(iterationName) AS iterationName,
MIN(iterationStartedAt) AS iterationStartedAt,
MIN(iterationPublishedAt) AS iterationPublishedAt,
MIN(iterationPausedAt) AS iterationPausedAt
FROM
`qubit-client-{{q_view_v01.project._parameter_value}}.{{q_view_v01.site._parameter_value}}__v2.aux_experience_iteration_variation_v01`
WHERE
experienceId IS NOT NULL
AND iterationId IS NOT NULL
AND variationMasterId IS NOT NULL
GROUP BY
1,
2,
3 ),
iteration_metadata AS
(
SELECT
experienceId,
variationMasterId,
iterationId,
iterationName,
iterationStartedAt,
iterationPausedAt,
IF (iterationPublishedAt IS NULL,
TRUE,
FALSE) AS inDraft,
IF (iterationId = FIRST_VALUE(iterationId) OVER (PARTITION BY experienceId, variationMasterId ORDER BY iterationStartedAt DESC),
TRUE,
FALSE) AS isLatestIteration
FROM
iterations
),
status AS
(
SELECT
*,
IF (isLatestIteration = TRUE
AND iterationPausedAt IS NULL
AND iterationStartedAt IS NOT NULL,
TRUE,
FALSE) AS isActive
FROM
iteration_metadata
),
latestName AS (
SELECT
ROW.experienceId,
ROW.experienceName
FROM (
SELECT
ARRAY_AGG(t
ORDER BY
meta_recordDate DESC
LIMIT
1)[
OFFSET
(0)] AS ROW
FROM
`qubit-client-{{q_view_v01.project._parameter_value}}.{{q_view_v01.site._parameter_value}}__v2.aux_experience_iteration_variation_v01` AS t
GROUP BY
experienceId,
experienceName
)
)
SELECT
CAST(status.experienceId AS STRING) experienceId,
CAST(experienceName as STRING) experienceName,
DATE(MIN(iterationStartedAt)) experience_first_published_at,
DATE(MAX(iterationPausedAt)) experience_last_paused_at,
MAX(isActive) AS is_active
FROM
status
LEFT JOIN
latestName on (status.experienceId = latestName.experienceId)
GROUP BY
1, 2
;;
}
dimension: experience_id {
type: string
sql: STRING(${TABLE}.experienceId) ;;
hidden: yes
}
dimension: experience_name {
type: string
sql: ${TABLE}.experienceName ;;
view_label: "Goal Achieved"
group_label: "Experience"
label: "Experience Name"
description: "The name of experience in app.qubit.com."
}
dimension: g_current_experience_status {
view_label: "Goal Achieved"
type: string
sql: IF(${TABLE}.is_active = true , "Active" , "Paused") ;;
label: "Current Experience Status "
description: "Status of the experience as of today."
group_label: "Experience"
}
dimension: g_experience_first_published_at {
view_label: "Goal Achieved"
type: date
sql: TIMESTAMP(${TABLE}.experience_first_published_at) ;;
group_label: "Experience"
description: "Date the first iteration of experience was published."
label: "Experience First Published At"
}
dimension: g_experience_last_paused_at {
view_label: "Goal Achieved"
type: date
sql: TIMESTAMP(${TABLE}.experience_last_paused_at) ;;
group_label: "Experience"
description: "Most recent date experience was paused."
label: "Experience Last Paused At"
}
}