-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube_dashboard.pp
280 lines (247 loc) · 5.41 KB
/
youtube_dashboard.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
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
dashboard "youtube" {
title = "YouTube Channel Dashboard"
documentation = file("./docs/youtube_dashboard.md")
container {
title = "Overview"
card {
query = query.youtube_channel_count
width = 3
type = "info"
}
card {
query = query.youtube_channel_uploads_count
width = 3
type = "info"
}
card {
query = query.youtube_channel_categories_count
width = 3
type = "info"
}
card {
query = query.youtube_channel_countries_count
width = 3
type = "info"
}
}
container {
title = "Performance Analysis"
chart {
type = "column"
title = "Top 10 YouTube Channels by Subscribers"
query = query.youtube_channel_top_10_by_subscribers
width = 6
series "subscribers" {
title = "Number of Subscribers"
color = "turquoise"
}
}
chart {
type = "column"
title = "Top 10 YouTube Channels: Video View vs Uploads"
query = query.youtube_channel_video_view_vs_uploads
width = 6
grouping = "compare"
legend {
display = "auto"
position = "top"
}
series "video_views" {
title = "Video Views"
color = "purple"
}
series "uploads" {
title = "Uploads"
color = "blue"
}
}
}
container {
title = "Category and Channel Type Analysis"
chart {
type = "column"
grouping = "compare"
title = "Subscriber vs Video View by Category"
query = query.youtube_channel_subscriber_vs_video_view_by_category
width = 6
}
chart {
type = "pie"
title = "Distribution of YouTube Channel Types"
query = query.youtube_channel_distribution_type
width = 6
}
}
container {
title = "Geographic Distribution and Earnings"
chart {
type = "donut"
title = "Distribution of YouTube Channels Based on country"
query = query.youtube_channel_distribution_by_country
width = 6
}
chart {
type = "column"
title = "Top 10 YouTube Channels distribution of earnings"
query = query.youtube_channel_distribution_earnings
width = 6
}
}
container {
title = "Subscriber and View Trends"
chart {
type = "line"
title = "Channel Subscriber Growth (Last 30 Days)"
query = query.youtube_channel_subscriber_growth_last_30_days
width = 6
series "Subscriber Growth (Last 30 Days)"{
title = "Subscriber Growth (Last 30 Days)"
color = "green"
}
}
chart {
type = "line"
title = "Channel View Growth (Last 30 Days)"
query = query.youtube_channel_view_growth_last_30_days
width = 6
series "View Growth (Last 30 Days)"{
title = "View Growth (Last 30 Days)"
color = "darkorange"
}
}
}
}
# Card Queries
query "youtube_channel_count" {
sql = <<-EOQ
select
count(*) as "Total Channels"
from
youtube_statistics;
EOQ
}
query "youtube_channel_uploads_count" {
sql = <<-EOQ
select
sum(uploads) as "Total Uploads"
from
youtube_statistics;
EOQ
}
query "youtube_channel_categories_count" {
sql = <<-EOQ
select
count(distinct category) as "Total Categories"
from
youtube_statistics;
EOQ
}
query "youtube_channel_countries_count" {
sql = <<-EOQ
select
count(distinct country) as "Total Countries"
from
youtube_statistics;
EOQ
}
# Chart Queries
query "youtube_channel_top_10_by_subscribers" {
sql = <<-EOQ
select
youtuber,
subscribers
from
youtube_statistics
order by
subscribers desc
limit 10;
EOQ
}
query "youtube_channel_video_view_vs_uploads" {
sql = <<-EOQ
select
youtuber,
video_views,
uploads
from
youtube_statistics
order by
video_views desc
limit 10;
EOQ
}
query "youtube_channel_subscriber_vs_video_view_by_category" {
sql = <<-EOQ
select
category,
sum(subscribers) as TotalSubscribers,
sum(video_views) as TotalVideoViews
from
youtube_statistics
group by
category
order by
TotalSubscribers, TotalVideoViews desc;
EOQ
}
query "youtube_channel_distribution_type" {
sql = <<-EOQ
select
channel_type,
count(*) as NumberOfChannels
from
youtube_statistics
group by
channel_type
order by
NumberOfChannels desc;
EOQ
}
query "youtube_channel_distribution_by_country" {
sql = <<-EOQ
select
country,
count(*) as NumberOfChannels
from
youtube_statistics
group by
country
order by
NumberOfChannels desc;
EOQ
}
query "youtube_channel_distribution_earnings" {
sql = <<-EOQ
select
youtuber,
highest_monthly_earnings,
highest_yearly_earnings
from
youtube_statistics
order by
highest_monthly_earnings desc
limit 10;
EOQ
}
query "youtube_channel_subscriber_growth_last_30_days" {
sql = <<-EOQ
select
youtuber,
subscribers_for_last_30_days as "Subscriber Growth (Last 30 Days)"
from
youtube_statistics
order by
youtuber;
EOQ
}
query "youtube_channel_view_growth_last_30_days" {
sql = <<-EOQ
select
youtuber,
video_views_for_the_last_30_days as "View Growth (Last 30 Days)"
from
youtube_statistics
order by
youtuber;
EOQ
}