-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube_channel_detail.pp
238 lines (210 loc) · 4.52 KB
/
youtube_channel_detail.pp
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
dashboard "youtube_channel_detail" {
title = "YouTube Channel Detail"
documentation = file("./docs/youtube_channel_detail.md")
input "youtube_id" {
title = "Select a Channel:"
query = query.youtube_channel_input
width = 4
}
container {
width = 12
card {
query = query.youtube_channel_type
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
card {
query = query.youtube_video_view_rank
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
card {
query = query.youtube_channel_uploads
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
card {
query = query.youtube_channel_subscribers
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
card {
query = query.youtube_channel_video_views
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
card {
query = query.youtube_channel_rank
width = 2
args = [self.input.youtube_id.value]
type = "info"
}
}
container {
width = 12
table {
title = "Channel Overview"
width = 4
type = "line"
query = query.youtube_channel_overview
args = [self.input.youtube_id.value]
}
chart {
title = "Monthly Earnings Distribution"
width = 4
type = "column"
query = query.youtube_channel_monthly_earnings_distribution
args = [self.input.youtube_id.value]
}
chart {
title = "Yearly Earnings Distribution"
width = 4
type = "column"
query = query.youtube_channel_yearly_earnings_distribution
args = [self.input.youtube_id.value]
}
}
}
# Input query
query "youtube_channel_input" {
sql = <<-EOQ
select
youtuber as label,
rank as value
from
youtube_statistics
order by
youtuber;
EOQ
}
# Card queries
query "youtube_channel_uploads" {
sql = <<-EOQ
select
'Total Uploads' as label,
uploads as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_channel_subscribers" {
sql = <<-EOQ
select
'Total Subscribers' as label,
subscribers as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_channel_video_views" {
sql = <<-EOQ
select
'Total Video Views' as label,
video_views as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_channel_rank" {
sql = <<-EOQ
select
'Channel Rank' as label,
channel_type_rank as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_channel_type" {
sql = <<-EOQ
select
'Channel Type' as label,
channel_type as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_video_view_rank" {
sql = <<-EOQ
select
'Video View Rank' as label,
video_views_rank as value
from
youtube_statistics
where
rank = $1;
EOQ
}
# Overview table query
query "youtube_channel_overview" {
sql = <<-EOQ
select
youtuber as "Channel",
created_month as "Created Month",
created_year as "Created Year",
country_rank as "Country Rank",
video_views_for_the_last_30_days as "Views (Last 30 Days)",
subscribers_for_last_30_days as "Subscribers (Last 30 Days)",
country as "Country",
population as "Country Population",
unemployment_rate as "Country Unemployment Rate",
gross_tertiary_education_enrollment_percent as "Country Gross Tertiary Education Enrollment Percent"
from
youtube_statistics
where
rank = $1;
EOQ
}
# Additional queries
query "youtube_channel_monthly_earnings_distribution" {
sql = <<-EOQ
select
'Lowest Monthly Earnings' as label,
lowest_monthly_earnings as value
from
youtube_statistics
where
rank = $1
union
select
'Highest Monthly Earnings' as label,
highest_monthly_earnings as value
from
youtube_statistics
where
rank = $1;
EOQ
}
query "youtube_channel_yearly_earnings_distribution" {
sql = <<-EOQ
select
'Lowest Yearly Earnings' as label,
lowest_yearly_earnings as value
from
youtube_statistics
where
rank = $1
union
select
'Highest Yearly Earnings' as label,
highest_yearly_earnings as value
from
youtube_statistics
where
rank = $1;
EOQ
}