forked from turbot/steampipe-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_reddits.sp
87 lines (76 loc) · 1.59 KB
/
search_reddits.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
dashboard "search_subreddits" {
tags = {
service = "reddit"
}
title = "Search subreddits"
container {
input "subreddit_name_match" {
width = 4
title = "match subreddit name"
type = "text"
}
input "subreddit_title_match" {
width = 2
title = "match title too?"
type = "select"
option "no" {}
option "yes" {}
}
}
container {
chart {
width = 6
type = "donut"
args = [
self.input.subreddit_name_match,
self.input.subreddit_title_match
]
sql = <<EOQ
select
subscribers,
display_name || ' (rank=' || rank || ')' as subreddit
from
reddit_subreddit_search
where
query = $1
and display_name ~ $1
and
case
when $2 = 'yes' then title ~ $1
else true
end
order by
subscribers desc
EOQ
}
table {
width = 6
args = [
self.input.subreddit_name_match,
self.input.subreddit_title_match
]
sql = <<EOQ
select
rank,
subscribers as subs,
'https://reddit.com/r/' || display_name as subreddit,
title
from
reddit_subreddit_search
where
query = $1
and display_name ~ $1
and
case
when $2 = 'yes' then title ~ $1
else true
end
order by
rank
EOQ
column "title" {
wrap = "all"
}
}
}
}