--
You received this message because you are subscribed to the Google Groups "chrome-ux-report" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-ux-repo...@chromium.org.
To post to this group, send email to chrome-u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chrome-ux-report/13f32814-e2ea-4eef-bf77-42322c506309%40chromium.org.
CREATE TEMPORARY FUNCTION spreadBins(bins ARRAY<STRUCT<start INT64, `end` INT64, density FLOAT64>>)
RETURNS ARRAY<STRUCT<client STRING, start INT64, density FLOAT64>>
LANGUAGE js AS """
// Convert into 100ms bins and spread the density around.
const WIDTH = 100;
return (bins || []).reduce((bins, bin) => {
bin.start = +bin.start;
bin.end = Math.min(bin.end, bin.start + 5000);
const binWidth = bin.end - bin.start;
for (let start = bin.start; start < bin.end; start += WIDTH) {
bins.push({
start,
density: bin.density / (binWidth / WIDTH)
});
}
return bins;
}, []);
""";
SELECT origin, form_factor.name as client,
"onload" as metric,
bin.start / 1000 AS bin,
SUM(bin.density) as volume
FROM (
SELECT origin, form_factor, spreadBins(onload.histogram.bin) AS bins
FROM `chrome-ux-report.all.201804`
WHERE origin IN ("http://www.example.com", "https://www.example.com")
)
CROSS JOIN UNNEST (bins) as bin
GROUP BY origin, client, bin
I have tried to use "WHERE origin Like "%.example.com", but percentages for each bucket/device look strange. The only way I can get the percentages to calculate correctly is to output the data separately for each protocol variant (http vs https) as in the example below.