-
Notifications
You must be signed in to change notification settings - Fork 16
/
issue_extended.view.lkml
420 lines (359 loc) · 10.7 KB
/
issue_extended.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
### ISSUE_EXTENDED
# The issue_extended table is designed to make it easier for
# end users to work with the issue table. The issue table
# contains many foreign keys to other tables and many subsidiary
# tables that contain the values of multi value select fields.
# This PDT is designed to consolidate all of that data in one
# place without the user having to worry about fanouts from joining
# to tables with multiple matching rows or any of the other complexities
# of working with the issue table.
# If any of the fields in the issue table aren't used as part of
# your business process, set them to "hidden: yes" to limit what the
# end user has to work with to only what they need.
# Make liberal user of "group_label" to organize the data in a way
# that is meaningful for your users. There can be lots of columns
# so make them as easy to work woth as possible.
explore: issue_extended {}
view: issue_extended {
derived_table: {
datagroup_trigger: fivetran_datagroup
sql: SELECT issue.*
-- Include the values associated with foreign keys
-- in the issue table
-- if you add a field in this section, you will
-- need to add another field to the GROUP BY clause
-- You will also need to add each one as a new
-- dimension below
-- department_name is used as an example of a custom single
-- value select field. Use it as a template for your single
-- select fields
,department.name as department_name
,project.name as project_name
,resolution.name as resolution_name
,severity.name as severity_name
,status.name as status_name
,issue_type.name as issue_type_name
-- Include all of the values for multi-value fields associated
-- with the issue. Each of these fields is stored in its
-- own separate table
-- We will use LISTAGG to combine them into a
-- single field so that we end up with a single record for
-- each issue
-- You will also need to add each one as a new
-- dimension below
-- Depending on your preferred output style, you may want to
-- use LISTAGG DISTINCT to eliminate duplicate values
-- supported_browsers is used as an example of a multi value
-- select field. Use it as a template for your multi-value
-- select fields
,LISTAGG(issue_supported_browsers.value, ', ') as browser_list
,LISTAGG(component.name, ', ') as component_list
,LISTAGG(version.name, ', ') as fix_version_list
,LISTAGG(issue_link.related_issue_id, ', ') as related_issues_list
FROM jira.issue issue
-- Single value fields.
-- If the field contains an id, look it up
-- in the appropriate table. Many of them will
-- be in the field_option table. The
-- field_option table must have a unique alias
-- each time it is referenced
LEFT OUTER JOIN jira.field_option department -- unique alias
ON issue.department = department.id
LEFT OUTER JOIN jira.project
ON issue.project = project.id
LEFT OUTER JOIN jira.field_option severity -- unique alias
ON issue.severity = severity.id
LEFT OUTER JOIN jira.status
ON issue.status = status.id
LEFT OUTER JOIN jira.issue_type
ON issue.issue_type = issue_type.id
-- Multi-value fields
LEFT OUTER JOIN jira.issue_supported_browsers
ON issue.id = issue_supported_browsers.issue_id
-- Multi vlaue field that stores ids. In this example
-- the issue_component table stores component_id's
-- which are looked up in the component table
LEFT OUTER JOIN jira.issue_component
ON issue.id = issue_component.issue_id
LEFT OUTER JOIN jira.component
ON issue_component.component_id = component.id
LEFT OUTER JOIN jira.issue_fix_version
ON issue.id = issue_fix_version.issue_id
LEFT OUTER JOIN jira.version
ON issue_fix_version_s.version_id = version.id
LEFT OUTER JOIN jira.issue_link
ON issue.id = issue_link.issue_id
-- Each non-aggregated field (not included in a LISTAGG) needs to
-- be included i the GROUP BY clause, so that's every field in the
-- issue table along with each additional single value field.
GROUP BY 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
;;
indexes: ["id"]
}
dimension: id {
primary_key: yes
type: number
sql: ${TABLE}.id ;;
}
dimension_group: _fivetran_synced {
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}._fivetran_synced ;;
}
dimension: external_issue_id {
type: string
sql: ${TABLE}.external_issue_id ;;
}
dimension: _original_estimate {
type: number
sql: ${TABLE}._original_estimate ;;
}
dimension: _remaining_estimate {
type: number
sql: ${TABLE}._remaining_estimate ;;
}
dimension: _time_spent {
type: number
sql: ${TABLE}._time_spent ;;
}
dimension: assignee {
type: string
sql: ${TABLE}.assignee ;;
}
dimension_group: created {
group_label: "Dates"
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.created ;;
}
dimension: department {
hidden: yes
type: number
sql: ${TABLE}.op_department ;;
}
# Additional dimension for the denormailzed department_name
dimension: department_name {
type: string
sql: ${TABLE}.op_department_name ;;
}
dimension: description {
type: string
sql: ${TABLE}.description ;;
}
dimension_group: due {
group_label: "Dates"
type: time
timeframes: [
raw,
date,
week,
month,
quarter,
year
]
convert_tz: no
sql: ${TABLE}.due_date ;;
}
dimension: environment {
type: string
sql: ${TABLE}.environment ;;
}
dimension: issue_type {
hidden: yes
type: number
sql: ${TABLE}.issue_type ;;
}
# Additional dimension for the denormailzed issue_type_name
dimension: issue_type_name {
type: string
sql: ${TABLE}.issue_type_name ;;
}
dimension: original_estimate {
type: number
sql: ${TABLE}.original_estimate ;;
}
dimension: project_id {
label: "Current Project"
hidden: yes
type: number
sql: ${TABLE}.project ;;
}
# Additional dimension for the denormailzed project_name
dimension: project_name {
label: "Current Project"
type: string
sql: ${TABLE}.project_name ;;
}
dimension: resolution {
group_label: "Resolution"
hidden: yes
type: number
sql: ${TABLE}.resolution ;;
}
# Additional dimension for the denormailzed resolution_name
dimension: resolution_name {
group_label: "Resolution"
type: string
sql: ${TABLE}.resolution_name ;;
}
dimension_group: resolved {
group_label: "Resolution"
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.resolved ;;
}
# Additional field for a simple way to determine
# if an issue is resolved
dimension: is_issue_resolved {
group_label: "Resolution"
type: yesno
sql: ${resolved_date} IS NOT NULL ;;
}
# Custom dimensions for time to resolve issue
dimension: hours_to_resolve_issue {
group_label: "Resolution"
label: "Time to Resolve (Hours)"
type: number
sql: DATEDIFF(h,${created_raw},${resolved_raw}) ;;
value_format_name: decimal_0
}
dimension: minutes_to_resolve_issue {
group_label: "Resolution"
label: "Time to Resolve (Minutes)"
type: number
sql: DATEDIFF(m,${created_raw},${resolved_raw}) ;;
value_format_name: decimal_0
}
dimension: days_to_resolve_issue {
group_label: "Resolution"
label: "Time to Resolve (Days)"
type: number
sql: DATEDIFF(d,${created_raw},${resolved_raw}) ;;
value_format_name: decimal_0
}
measure: total_time_to_resolve_issues_hours {
group_label: "Resolution"
label: "Total Time to Resolve Issues per Grouping"
description: "The total hours required to resolve all issues in the chosen dimension grouping"
type: sum
sql: ${days_to_resolve_issue} ;;
value_format_name: decimal_0
}
measure: avg_time_to_resolve_issues_hours {
group_label: "Resolution"
label: "Avg Time to Resolve Issues per Grouping"
description: "The average hours required to resolve all issues in the chosen dimension grouping"
type: average
sql: ${days_to_resolve_issue} ;;
value_format_name: decimal_0
}
dimension: severity {
hidden: yes
type: number
sql: ${TABLE}.severity ;;
}
dimension: severity_name {
type: string
sql: ${TABLE}.severity_name ;;
}
dimension: status {
hidden: yes
type: number
sql: ${TABLE}.status ;;
}
dimension: status_name {
type: string
sql: ${TABLE}.status_name ;;
}
dimension: story_points {
type: number
sql: ${TABLE}.story_points ;;
}
measure: total_story_points {
type: sum
sql: ${story_points} ;;
}
# # measure: total_open_story_points {
# type: sum
# sql: ${story_points} ;;
## filters: {
# field: status.name
# value:"Open, In Progress, In Development, In QA, In Review"
# }
# }
# measure: total_closed_story_points {
# type: sum
# sql: ${story_points} ;;
# filters: {
# field: status.name
# value:"Closed, Done, Ready for Production"
# }
# }
dimension_group: updated {
group_label: "Dates"
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.updated ;;
}
## Additional dimensions for the LISTAGGS defined
## in the query
dimension: browser_list {
type: string
sql: ${TABLE}.browser_list ;;
}
dimension: component_list {
type: string
sql: ${TABLE}.component_list ;;
}
dimension: fix_version_list {
type: string
sql: ${TABLE}.fix_version_list ;;
}
dimension: related_issues_list {
type: string
sql: ${TABLE}.related_issues_list ;;
}
measure: count {
type: count
drill_fields: [id, days_to_resolve_issue, created_date, severity ]
}
# ----- Sets of fields for drilling ------
#set: detail {
# fields: [
# external_issue_id,
# ]
#}
}