This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
forked from llooker/intercom_by_blendo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolution_metrics.view.lkml
108 lines (90 loc) · 2.71 KB
/
resolution_metrics.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
view: resolution_metrics {
derived_table: {
sql: SELECT abs(EXTRACT(epoch FROM (fRe.fullResolution - fOp.firstOpen))/3600) as fullRes_dif,
abs(EXTRACT(epoch FROM (fRe.firstResolution - fOp.firstOpen))/3600) as firstRes_dif,
abs(EXTRACT(epoch FROM (fCo.firstComment - fOp.firstOpen))/3600) as firstResp_dif,
fRe.fullResolution as date,
fRe.conversation_id as conversation_id
FROM
(SELECT conversation_id, min(updated_at) AS firstResolution,
max(updated_at) AS fullResolution
FROM intercom.conversation_parts
WHERE part_type='close'
GROUP BY conversation_id) fRe,
(SELECT conversation_id,
min(updated_at) AS firstOpen
FROM intercom.conversation_parts
WHERE part_type='comment'
AND author_type='user'
GROUP BY conversation_id) fOp,
(SELECT conversation_id,
min(updated_at) AS firstComment
FROM intercom.conversation_parts
WHERE part_type='comment'
AND author_type='admin'
GROUP BY conversation_id) fCo
WHERE fRe.conversation_id=fOp.conversation_id and fCo.conversation_id=fOp.conversation_id
AND (fRe.fullResolution - fOp.firstOpen)>=interval '0' AND (fCo.firstComment - fOp.firstOpen)>=interval '0'
;;
}
dimension: conversation_id {
description: "Unique identifier of related conversation"
type: string
primary_key: yes
sql: ${TABLE}.conversation_id ;;
}
measure: full_Resolution_maximum {
type: max
sql: ${TABLE}.fullRes_dif ;;
}
measure: full_Resolution_minimum {
type: min
sql:${TABLE}.fullRes_dif ;;
}
measure: full_Resolution_average {
type: average
sql:${TABLE}.fullRes_dif ;;
}
measure: full_Resolution_median {
type: median
sql:${TABLE}.fullRes_dif ;;
}
measure: first_Resolution_maximum {
type: max
sql: ${TABLE}.firstRes_dif ;;
}
measure: first_Resolution_minimum {
type: min
sql:${TABLE}.firstRes_dif ;;
}
measure: first_Resolution_average {
type: average
sql:${TABLE}.firstRes_dif ;;
}
measure: first_Resolution_median {
type: median
sql:${TABLE}.firstRes_dif ;;
}
measure: first_Response_maximum {
type: max
sql: ${TABLE}.firstResp_dif ;;
}
measure: first_Response_minimum {
type: min
sql:${TABLE}.firstResp_dif ;;
}
measure: first_Response_average {
type: average
sql:${TABLE}.firstResp_dif ;;
}
measure: first_Response_median {
type: median
sql:${TABLE}.firstResp_dif ;;
}
dimension_group: date {
type: time
timeframes: [date, day_of_week, week, month]
sql: ${TABLE}.date ;;
drill_fields: [date_date, date_day_of_week, date_week, date_month]
}
}