forked from turbot/steampipe-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.sp
119 lines (108 loc) · 2.38 KB
/
mod.sp
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
mod "github" {
title = "github"
}
locals {
default_org = {
name = "turbot"
}
default_user = {
name = "judell"
}
}
dashboard "github_activity" {
input "username" {
title = "username"
width = 2
query = query.usernames
}
input "repo_pattern" {
title = "repo pattern"
width = 2
option "turbot" {}
option "steampipe-mod" {}
option "steampipe-plugin" {}
}
input "issue_or_pull" {
title = "issue/pull"
width = 2
option "issue" {}
option "pull" {}
option "both" {}
}
input "open_or_closed" {
title = "open/closed"
width = 2
option "open" {}
option "closed" {}
option "both" {}
}
container {
table {
title = "my team's github activity"
width = 12
args = [
self.input.username.value,
self.input.repo_pattern.value,
self.input.issue_or_pull.value,
self.input.open_or_closed.value
]
sql = <<EOT
select
html_url,
title,
to_char(updated_at, 'YYYY-MM-DD') as updated_at,
to_char(created_at, 'YYYY-MM-DD') as created_at,
to_char(closed_at, 'YYYY-MM-DD') as closed_at
from
github_activity(
$1,
$2,
''
)
where
html_url ~
case
when $3 = 'issue' then 'issue'
when $3 = 'pull' then 'pull'
else 'issue|pull'
end
and case
when $4 = 'open' then closed_at is null
when $4 = 'closed' then closed_at is not null
else closed_at is null or closed_at is not null
end
EOT
param "username" {}
param "repo_pattern" {}
param "issue_or_pull" {}
param "open_or_closed" {}
column "url"{
wrap = "all"
}
column "title" {
wrap = "all"
}
}
}
}
query "usernames" {
sql = <<EOT
with user_info as (
select
jsonb_array_elements_text(member_logins) as member_login
from
github_organization
where
login = '${local.default_org.name}'
)
select
'${local.default_user.name}' as label,
'${local.default_user.name}' as value
union all
select
member_login as label,
member_login as value
from
user_info
EOT
}