-
Notifications
You must be signed in to change notification settings - Fork 11
/
rum-dashboard.sql
593 lines (576 loc) · 20.7 KB
/
rum-dashboard.sql
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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
--- description: Get Helix RUM data for a given domain or owner/repo combination
--- Authorization: none
--- Access-Control-Allow-Origin: *
--- limit: 10
--- interval: 30
--- offset: 0
--- startdate: 2022-02-01
--- enddate: 2022-05-28
--- timezone: UTC
--- url: -
--- owner: -
--- repo: -
--- device: all
--- rising: false
--- domainkey: secret
CREATE TEMP FUNCTION FILTERCLASS(user_agent STRING, device STRING)
RETURNS BOOLEAN
AS (
device = "all"
OR (
device = "desktop"
AND user_agent NOT LIKE "%Mobile%"
AND user_agent LIKE "Mozilla%"
)
OR (device = "mobile" AND user_agent LIKE "%Mobile%")
OR (device = "bot" AND user_agent NOT LIKE "Mozilla%")
);
WITH
current_data AS (
SELECT * FROM
helix_rum.EVENTS_V5(
@url, # domain or URL
CAST(@offset AS INT64), # not used, offset in days from today
CAST(@interval AS INT64), # interval in days to consider
@startdate, # not used, start date
@enddate, # not used, end date
@timezone, # timezone
@device, # device class
@domainkey
)
),
previous_data AS (
SELECT * FROM
helix_rum.EVENTS_V5(
@url, # domain or URL
# offset in days from today
CAST(@interval AS INT64) + CAST(@offset AS INT64),
CAST(@interval AS INT64), # interval in days to consider
FORMAT_DATE("%F", DATE_SUB(@startdate, INTERVAL ABS(DATE_DIFF(DATE(@enddate, @timezone), DATE(@startdate, @timezone), DAY)) DAY)), # not used, start date
@startdate, # not used, end date
@timezone, # timezone
@device, # device class
@domainkey
)
),
current_rum_by_id AS (
SELECT
id,
IF(MAX(lcp) IS NULL, NULL, IF(MAX(lcp) <= 2500, TRUE, FALSE)) AS lcpgood,
IF(MAX(fid) IS NULL, NULL, IF(MAX(fid) <= 100, TRUE, FALSE)) AS fidgood,
IF(MAX(inp) IS NULL, NULL, IF(MAX(inp) <= 200, TRUE, FALSE)) AS inpgood,
IF(MAX(cls) IS NULL, NULL, IF(MAX(cls) <= 0.1, TRUE, FALSE)) AS clsgood,
IF(MAX(ttfb) IS NULL, NULL, IF(MAX(ttfb) <= 800, TRUE, FALSE)) AS ttfbgood,
IF(MAX(lcp) IS NULL, NULL, IF(MAX(lcp) >= 4000, TRUE, FALSE)) AS lcpbad,
IF(MAX(fid) IS NULL, NULL, IF(MAX(fid) >= 300, TRUE, FALSE)) AS fidbad,
IF(MAX(inp) IS NULL, NULL, IF(MAX(fid) >= 500, TRUE, FALSE)) AS inpbad,
IF(MAX(cls) IS NULL, NULL, IF(MAX(cls) >= 0.25, TRUE, FALSE)) AS clsbad,
IF(MAX(ttfb) IS NULL, NULL, IF(MAX(ttfb) >= 1800, TRUE, FALSE)) AS ttfbbad,
MAX(host) AS host,
MAX(user_agent) AS user_agent,
IF(
@url = "-" AND @repo = "-" AND @owner = "-",
REGEXP_EXTRACT(MAX(url), "https://([^/]+)/", 1),
MAX(url)
) AS url,
MAX(lcp) AS lcp,
MAX(fid) AS fid,
MAX(inp) AS inp,
MAX(cls) AS cls,
MAX(ttfb) AS ttfb,
MAX(referer) AS referer,
MAX(weight) AS weight
FROM current_data
WHERE
url LIKE CONCAT(
"https://", @url, "%"
) OR url LIKE CONCAT(
"https://%", @repo, "--", @owner, ".hlx%/"
) OR (@url = "-" AND @repo = "-" AND @owner = "-")
GROUP BY id
),
previous_rum_by_id AS (
SELECT
id,
IF(MAX(lcp) IS NULL, NULL, IF(MAX(lcp) <= 2500, TRUE, FALSE)) AS lcpgood,
IF(MAX(fid) IS NULL, NULL, IF(MAX(fid) <= 100, TRUE, FALSE)) AS fidgood,
IF(MAX(inp) IS NULL, NULL, IF(MAX(inp) <= 200, TRUE, FALSE)) AS inpgood,
IF(MAX(cls) IS NULL, NULL, IF(MAX(cls) <= 0.1, TRUE, FALSE)) AS clsgood,
IF(MAX(ttfb) IS NULL, NULL, IF(MAX(ttfb) <= 800, TRUE, FALSE)) AS ttfbgood,
IF(MAX(lcp) IS NULL, NULL, IF(MAX(lcp) >= 4000, TRUE, FALSE)) AS lcpbad,
IF(MAX(fid) IS NULL, NULL, IF(MAX(fid) >= 300, TRUE, FALSE)) AS fidbad,
IF(MAX(inp) IS NULL, NULL, IF(MAX(inp) >= 500, TRUE, FALSE)) AS inpbad,
IF(MAX(cls) IS NULL, NULL, IF(MAX(cls) >= 0.25, TRUE, FALSE)) AS clsbad,
IF(MAX(ttfb) IS NULL, NULL, IF(MAX(ttfb) >= 1800, TRUE, FALSE)) AS ttfbbad,
MAX(host) AS host,
MAX(user_agent) AS user_agent,
IF(
@url = "-" AND @repo = "-" AND @owner = "-",
REGEXP_EXTRACT(MAX(url), "https://([^/]+)/", 1),
MAX(url)
) AS url,
MAX(lcp) AS lcp,
MAX(fid) AS fid,
MAX(inp) AS inp,
MAX(cls) AS cls,
MAX(ttfb) AS ttfb,
MAX(referer) AS referer,
MAX(weight) AS weight
FROM previous_data
WHERE
url LIKE CONCAT(
"https://", @url, "%"
) OR url LIKE CONCAT(
"https://%", @repo, "--", @owner, ".hlx%/"
) OR (@url = "-" AND @repo = "-" AND @owner = "-")
GROUP BY id
),
current_rum_by_url_and_weight AS (
SELECT
weight,
url,
CAST(
100 * IF(
COUNTIF(lcpgood IS NOT NULL) != 0,
COUNTIF(lcpgood = TRUE) / COUNTIF(lcpgood IS NOT NULL),
NULL
) AS INT64
) AS lcpgood,
CAST(
100 * IF(
COUNTIF(fidgood IS NOT NULL) != 0,
COUNTIF(fidgood = TRUE) / COUNTIF(fidgood IS NOT NULL),
NULL
) AS INT64
) AS fidgood,
CAST(
100 * IF(
COUNTIF(inpgood IS NOT NULL) != 0,
COUNTIF(inpgood = TRUE) / COUNTIF(inpgood IS NOT NULL),
NULL
) AS INT64
) AS inpgood,
CAST(
100 * IF(
COUNTIF(clsgood IS NOT NULL) != 0,
COUNTIF(clsgood = TRUE) / COUNTIF(clsgood IS NOT NULL),
NULL
) AS INT64
) AS clsgood,
CAST(
100 * IF(
COUNTIF(ttfbgood IS NOT NULL) != 0,
COUNTIF(ttfbgood = TRUE) / COUNTIF(ttfbgood IS NOT NULL),
NULL
) AS INT64
) AS ttfbgood,
CAST(
100 * IF(
COUNTIF(lcpbad IS NOT NULL) != 0,
COUNTIF(lcpbad = TRUE) / COUNTIF(lcpbad IS NOT NULL),
NULL
) AS INT64
) AS lcpbad,
CAST(
100 * IF(
COUNTIF(fidbad IS NOT NULL) != 0,
COUNTIF(fidbad = TRUE) / COUNTIF(fidbad IS NOT NULL),
NULL
) AS INT64
) AS fidbad,
CAST(
100 * IF(
COUNTIF(inpbad IS NOT NULL) != 0,
COUNTIF(inpbad = TRUE) / COUNTIF(inpbad IS NOT NULL),
NULL
) AS INT64
) AS inpbad,
CAST(
100 * IF(
COUNTIF(clsbad IS NOT NULL) != 0,
COUNTIF(clsbad = TRUE) / COUNTIF(clsbad IS NOT NULL),
NULL
) AS INT64
) AS clsbad,
CAST(
100 * IF(
COUNTIF(ttfbbad IS NOT NULL) != 0,
COUNTIF(ttfbbad = TRUE) / COUNTIF(ttfbbad IS NOT NULL),
NULL
) AS INT64
) AS ttfbbad,
CAST(APPROX_QUANTILES(lcp, 100)[OFFSET(75)] AS INT64) AS avglcp,
CAST(APPROX_QUANTILES(fid, 100)[OFFSET(75)] AS INT64) AS avgfid,
CAST(APPROX_QUANTILES(inp, 100)[OFFSET(75)] AS INT64) AS avginp,
ROUND(APPROX_QUANTILES(cls, 100)[OFFSET(75)], 3) AS avgcls,
CAST(APPROX_QUANTILES(ttfb, 100)[OFFSET(75)] AS INT64) AS avgttfb,
COUNT(id) AS events
FROM current_rum_by_id
GROUP BY url, weight
ORDER BY events DESC
),
previous_rum_by_url_and_weight AS (
SELECT
weight,
url,
CAST(
100 * IF(
COUNTIF(lcpgood IS NOT NULL) != 0,
COUNTIF(lcpgood = TRUE) / COUNTIF(lcpgood IS NOT NULL),
NULL
) AS INT64
) AS lcpgood,
CAST(
100 * IF(
COUNTIF(fidgood IS NOT NULL) != 0,
COUNTIF(fidgood = TRUE) / COUNTIF(fidgood IS NOT NULL),
NULL
) AS INT64
) AS fidgood,
CAST(
100 * IF(
COUNTIF(inpgood IS NOT NULL) != 0,
COUNTIF(inpgood = TRUE) / COUNTIF(inpgood IS NOT NULL),
NULL
) AS INT64
) AS inpgood,
CAST(
100 * IF(
COUNTIF(clsgood IS NOT NULL) != 0,
COUNTIF(clsgood = TRUE) / COUNTIF(clsgood IS NOT NULL),
NULL
) AS INT64
) AS clsgood,
CAST(
100 * IF(
COUNTIF(ttfbgood IS NOT NULL) != 0,
COUNTIF(ttfbgood = TRUE) / COUNTIF(ttfbgood IS NOT NULL),
NULL
) AS INT64
) AS ttfbgood,
CAST(
100 * IF(
COUNTIF(lcpbad IS NOT NULL) != 0,
COUNTIF(lcpbad = TRUE) / COUNTIF(lcpbad IS NOT NULL),
NULL
) AS INT64
) AS lcpbad,
CAST(
100 * IF(
COUNTIF(fidbad IS NOT NULL) != 0,
COUNTIF(fidbad = TRUE) / COUNTIF(fidbad IS NOT NULL),
NULL
) AS INT64
) AS fidbad,
CAST(
100 * IF(
COUNTIF(inpbad IS NOT NULL) != 0,
COUNTIF(inpbad = TRUE) / COUNTIF(inpbad IS NOT NULL),
NULL
) AS INT64
) AS inpbad,
CAST(
100 * IF(
COUNTIF(clsbad IS NOT NULL) != 0,
COUNTIF(clsbad = TRUE) / COUNTIF(clsbad IS NOT NULL),
NULL
) AS INT64
) AS clsbad,
CAST(
100 * IF(
COUNTIF(ttfbbad IS NOT NULL) != 0,
COUNTIF(ttfbbad = TRUE) / COUNTIF(ttfbbad IS NOT NULL),
NULL
) AS INT64
) AS ttfbbad,
CAST(APPROX_QUANTILES(lcp, 100)[OFFSET(75)] AS INT64) AS avglcp,
CAST(APPROX_QUANTILES(fid, 100)[OFFSET(75)] AS INT64) AS avgfid,
CAST(APPROX_QUANTILES(inp, 100)[OFFSET(75)] AS INT64) AS avginp,
ROUND(APPROX_QUANTILES(cls, 100)[OFFSET(75)], 3) AS avgcls,
CAST(APPROX_QUANTILES(ttfb, 100)[OFFSET(75)] AS INT64) AS avgttfb,
COUNT(id) AS events
FROM previous_rum_by_id
GROUP BY url, weight
ORDER BY events DESC
),
current_rum_by_url AS (
SELECT
url,
SUM(lcpgood * weight) / SUM(weight) AS lcpgood,
SUM(fidgood * weight) / SUM(weight) AS fidgood,
SUM(inpgood * weight) / SUM(weight) AS inpgood,
SUM(clsgood * weight) / SUM(weight) AS clsgood,
SUM(ttfbgood * weight) / SUM(weight) AS ttfbgood,
SUM(lcpbad * weight) / SUM(weight) AS lcpbad,
SUM(fidbad * weight) / SUM(weight) AS fidbad,
SUM(inpbad * weight) / SUM(weight) AS inpbad,
SUM(clsbad * weight) / SUM(weight) AS clsbad,
SUM(ttfbbad * weight) / SUM(weight) AS ttfbbad,
SUM(avglcp * weight) / SUM(weight) AS avglcp,
SUM(avgfid * weight) / SUM(weight) AS avgfid,
SUM(avginp * weight) / SUM(weight) AS avginp,
ROUND(SUM(avgcls * weight) / SUM(weight), 3) AS avgcls,
SUM(avgttfb * weight) / SUM(weight) AS avgttfb,
SUM(events * weight) AS pageviews
FROM current_rum_by_url_and_weight
GROUP BY url
ORDER BY pageviews DESC
),
previous_rum_by_url AS (
SELECT
url,
SUM(lcpgood * weight) / SUM(weight) AS lcpgood,
SUM(fidgood * weight) / SUM(weight) AS fidgood,
SUM(inpgood * weight) / SUM(weight) AS inpgood,
SUM(clsgood * weight) / SUM(weight) AS clsgood,
SUM(ttfbgood * weight) / SUM(weight) AS ttfbgood,
SUM(lcpbad * weight) / SUM(weight) AS lcpbad,
SUM(fidbad * weight) / SUM(weight) AS fidbad,
SUM(inpbad * weight) / SUM(weight) AS inpbad,
SUM(clsbad * weight) / SUM(weight) AS clsbad,
SUM(ttfbbad * weight) / SUM(weight) AS ttfbbad,
SUM(avglcp * weight) / SUM(weight) AS avglcp,
SUM(avgfid * weight) / SUM(weight) AS avgfid,
SUM(avginp * weight) / SUM(weight) AS avginp,
ROUND(SUM(avgcls * weight) / SUM(weight), 3) AS avgcls,
SUM(avgttfb * weight) / SUM(weight) AS avgttfb,
SUM(events * weight) AS pageviews
FROM previous_rum_by_url_and_weight
GROUP BY url
ORDER BY pageviews DESC
),
current_event_count AS (
SELECT SUM(events) AS allevents FROM (
SELECT
id,
MAX(weight) AS events
FROM current_data
GROUP BY id
)
),
previous_event_count AS (
SELECT SUM(events) AS allevents FROM (
SELECT
id,
MAX(weight) AS events
FROM previous_data
GROUP BY id
)
),
current_truncated_rum_by_url AS (
SELECT
CAST(SUM(ranked.lcpgood * pageviews) / SUM(pageviews) AS INT64) AS lcpgood,
CAST(SUM(ranked.fidgood * pageviews) / SUM(pageviews) AS INT64) AS fidgood,
CAST(SUM(ranked.inpgood * pageviews) / SUM(pageviews) AS INT64) AS inpgood,
CAST(SUM(ranked.clsgood * pageviews) / SUM(pageviews) AS INT64) AS clsgood,
CAST(SUM(ranked.ttfbgood * pageviews) / SUM(pageviews) AS INT64) AS ttfbgood,
CAST(SUM(ranked.lcpbad * pageviews) / SUM(pageviews) AS INT64) AS lcpbad,
CAST(SUM(ranked.fidbad * pageviews) / SUM(pageviews) AS INT64) AS fidbad,
CAST(SUM(ranked.inpbad * pageviews) / SUM(pageviews) AS INT64) AS inpbad,
CAST(SUM(ranked.clsbad * pageviews) / SUM(pageviews) AS INT64) AS clsbad,
CAST(SUM(ranked.ttfbbad * pageviews) / SUM(pageviews) AS INT64) AS ttfbbad,
CAST(SUM(ranked.avglcp * pageviews) / SUM(pageviews) AS INT64) AS avglcp,
CAST(SUM(ranked.avgfid * pageviews) / SUM(pageviews) AS INT64) AS avgfid,
CAST(SUM(ranked.avginp * pageviews) / SUM(pageviews) AS INT64) AS avginp,
ROUND(SUM(ranked.avgcls * pageviews) / SUM(pageviews), 3) AS avgcls,
CAST(SUM(ranked.avgttfb * pageviews) / SUM(pageviews) AS INT64) AS avgttfb,
SUM(ranked.pageviews) AS pageviews,
100 * SUM(pageviews) / MAX(current_event_count.allevents) AS rumshare,
IF(ranked.rank > @limit AND NOT @rising, "Other", ranked.url) AS url
FROM
(SELECT
pageviews,
lcpgood,
fidgood,
inpgood,
clsgood,
ttfbgood,
lcpbad,
fidbad,
inpbad,
clsbad,
ttfbbad,
avglcp,
avgfid,
avginp,
avgcls,
avgttfb,
url,
ROW_NUMBER() OVER (ORDER BY pageviews DESC) AS rank
FROM current_rum_by_url) AS ranked,
current_event_count
GROUP BY url
),
previous_truncated_rum_by_url AS (
SELECT
CAST(SUM(ranked.lcpgood * pageviews) / SUM(pageviews) AS INT64) AS lcpgood,
CAST(SUM(ranked.fidgood * pageviews) / SUM(pageviews) AS INT64) AS fidgood,
CAST(SUM(ranked.inpgood * pageviews) / SUM(pageviews) AS INT64) AS inpgood,
CAST(SUM(ranked.clsgood * pageviews) / SUM(pageviews) AS INT64) AS clsgood,
CAST(SUM(ranked.ttfbgood * pageviews) / SUM(pageviews) AS INT64) AS ttfbgood,
CAST(SUM(ranked.lcpbad * pageviews) / SUM(pageviews) AS INT64) AS lcpbad,
CAST(SUM(ranked.fidbad * pageviews) / SUM(pageviews) AS INT64) AS fidbad,
CAST(SUM(ranked.inpbad * pageviews) / SUM(pageviews) AS INT64) AS inpbad,
CAST(SUM(ranked.clsbad * pageviews) / SUM(pageviews) AS INT64) AS clsbad,
CAST(SUM(ranked.ttfbbad * pageviews) / SUM(pageviews) AS INT64) AS ttfbbad,
CAST(SUM(ranked.avglcp * pageviews) / SUM(pageviews) AS INT64) AS avglcp,
CAST(SUM(ranked.avgfid * pageviews) / SUM(pageviews) AS INT64) AS avgfid,
CAST(SUM(ranked.avginp * pageviews) / SUM(pageviews) AS INT64) AS avginp,
ROUND(SUM(ranked.avgcls * pageviews) / SUM(pageviews), 3) AS avgcls,
CAST(SUM(ranked.avgttfb * pageviews) / SUM(pageviews) AS INT64) AS avgttfb,
SUM(ranked.pageviews) AS pageviews,
100 * SUM(pageviews) / MAX(previous_event_count.allevents) AS rumshare,
IF(ranked.rank > @limit AND NOT @rising, "Other", ranked.url) AS url
FROM
(SELECT
*,
ROW_NUMBER() OVER (ORDER BY pageviews DESC) AS rank
FROM previous_rum_by_url) AS ranked,
previous_event_count
GROUP BY url
)
SELECT
url,
pageviews,
pageviews_1,
pageviews_diff,
lcpgood,
fidgood,
inpgood,
clsgood,
ttfbgood,
lcpbad,
fidbad,
inpbad,
clsbad,
ttfbbad,
avglcp,
avgfid,
avginp,
avgcls,
avgttfb,
rumshare,
lcpgood_1,
fidgood_1,
inpgood_1,
clsgood_1,
ttfbgood_1,
lcpbad_1,
fidbad_1,
inpbad_1,
clsbad_1,
ttfbbad_1,
avglcp_1,
avgfid_1,
avginp_1,
avgcls_1,
avgttfb_1,
rumshare_1,
url_1
FROM (
SELECT
current_truncated_rum_by_url.pageviews AS pageviews,
previous_truncated_rum_by_url.pageviews AS pageviews_1,
current_truncated_rum_by_url.lcpgood AS lcpgood,
current_truncated_rum_by_url.fidgood AS fidgood,
current_truncated_rum_by_url.inpgood AS inpgood,
current_truncated_rum_by_url.clsgood AS clsgood,
current_truncated_rum_by_url.ttfbgood AS ttfbgood,
current_truncated_rum_by_url.lcpbad AS lcpbad,
current_truncated_rum_by_url.fidbad AS fidbad,
current_truncated_rum_by_url.inpbad AS inpbad,
current_truncated_rum_by_url.clsbad AS clsbad,
current_truncated_rum_by_url.ttfbbad AS ttfbbad,
current_truncated_rum_by_url.avglcp AS avglcp,
current_truncated_rum_by_url.avgfid AS avgfid,
current_truncated_rum_by_url.avginp AS avginp,
current_truncated_rum_by_url.avgcls AS avgcls,
current_truncated_rum_by_url.avgttfb AS avgttfb,
current_truncated_rum_by_url.rumshare AS rumshare,
previous_truncated_rum_by_url.lcpgood AS lcpgood_1,
previous_truncated_rum_by_url.fidgood AS fidgood_1,
previous_truncated_rum_by_url.inpgood AS inpgood_1,
previous_truncated_rum_by_url.clsgood AS clsgood_1,
previous_truncated_rum_by_url.ttfbgood AS ttfbgood_1,
previous_truncated_rum_by_url.lcpbad AS lcpbad_1,
previous_truncated_rum_by_url.fidbad AS fidbad_1,
previous_truncated_rum_by_url.inpbad AS inpbad_1,
previous_truncated_rum_by_url.clsbad AS clsbad_1,
previous_truncated_rum_by_url.ttfbbad AS ttfbbad_1,
previous_truncated_rum_by_url.avglcp AS avglcp_1,
previous_truncated_rum_by_url.avgfid AS avgfid_1,
previous_truncated_rum_by_url.avginp AS avginp_1,
previous_truncated_rum_by_url.avgcls AS avgcls_1,
previous_truncated_rum_by_url.avgttfb AS avgttfb_1,
previous_truncated_rum_by_url.rumshare AS rumshare_1,
previous_truncated_rum_by_url.url AS url_1,
ROW_NUMBER() OVER (
ORDER BY
IF(
@rising,
COALESCE(
current_truncated_rum_by_url.pageviews, 0
) - COALESCE(previous_truncated_rum_by_url.pageviews, 0),
0
) DESC,
current_truncated_rum_by_url.pageviews DESC
) AS rank,
COALESCE(
current_truncated_rum_by_url.url, previous_truncated_rum_by_url.url
) AS url,
COALESCE(
current_truncated_rum_by_url.pageviews, 0
) - COALESCE(previous_truncated_rum_by_url.pageviews, 0) AS pageviews_diff
FROM
current_truncated_rum_by_url FULL OUTER JOIN previous_truncated_rum_by_url
ON current_truncated_rum_by_url.url = previous_truncated_rum_by_url.url
ORDER BY
IF(current_truncated_rum_by_url.url = "Other", 1, 0),
IF(
@rising,
COALESCE(
current_truncated_rum_by_url.pageviews, 0
) - COALESCE(previous_truncated_rum_by_url.pageviews, 0),
0
) DESC,
current_truncated_rum_by_url.pageviews DESC,
previous_truncated_rum_by_url.pageviews DESC
) WHERE
rank <= @limit OR url = "Other" OR @rising
--- avgcls: 75th percentile value of the Cumulative Layout Shift metric in the current period
--- avgcls_1: 75th percentile value of the CLS metric in the previous period
--- avgfid: 75th percentile value of the First Input Delay metric in milliseconds in the current period
--- avgfid_1: 75th percentile value of FID in the previous period
--- avginp: 75th percentile value of the Interaction to Next Paint metric in milliseconds in the current period
--- avginp_1: 75th percentile of INP in the previous period
--- avglcp: 75th percentile of the Largest Contentful Paint metric in milliseconds in the current period
--- avglcp_1: 75th percentile of LCP in the previous period
--- avgttfb: 75th percentile of the Time to First Byte metric in milliseconds in the current period
--- avgttfb_1: 75th percentile of TTFB in the previous period
--- clsbad: percentage of all page views where Cumulative Layout Shift is in the “needs improvement” range in the current period
--- clsbad_1: percentage of of all page views with bad CLS in the previous period
--- clsgood: percentage of all page views where the CLS metric is in the “good” range in the current period
--- clsgood_1: percentage of pageviews with good CLS the the previous period
--- fidbad: percentage of pageviews with bad FID in the current period
--- fidbad_1: percentage of pageviews with bad FID in the previous period
--- fidgood: percentage of pageviews with good FID in the current period
--- fidgood_1: percentage of pageviews with good FID in the previous period
--- inpbad: percentage of pageviews with bad INP in the current period
--- inpbad_1: percentage of pageviews with bad INP in the previous period
--- inpgood: percentage of pageviews with good INP in the current period
--- inpgood_1: percentage of pageviews with bad INP in the previous period
--- lcpbad: percentage of pageviews with bad LCP in the current period
--- lcpbad_1: percentage of pageviews with bad LCP in the previous period
--- lcpgood: percentage of pageviews with good LCP in the current period
--- lcpgood_1: percentage of pageviews with good LCP in the current period
--- ttfbbad: percentage of pageviews with bad TTFB in the current period
--- ttfbbad_1: percentage of pageviews with bad TTFB in the previous period
--- ttfbgood: percentage of pageviews with good TTFB in the current period
--- ttfbgood_1: percentage of pageviews with good TTFB in the current period
--- pageviews: estimated number of pageviews in the current period
--- pageviews_1: estimated number of pageviews in the previous period
--- pageviews_diff: difference in pageviews between the current and previous period. If the parameter rising is true, then pages will be ranked according to this value
--- rumshare: percentage of all traffic for the given domain that is going to this url in the current period
--- rumshare_1: percentage of of all traffic in the previous domain that is going to this url in the previous period
--- url: the URL of the page that is getting traffic
--- url_1: the URL of the page that is getting traffic in the previous period (these last two values are always the same)