Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group RUM data optionally by generation #497

Open
trieloff opened this issue Sep 8, 2021 · 0 comments
Open

Group RUM data optionally by generation #497

trieloff opened this issue Sep 8, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@trieloff
Copy link
Contributor

trieloff commented Sep 8, 2021

naive generation grouping

WITH by_generation AS (
SELECT 
    id,
    generation,
    IF(url IN (
        "https://www.adobe.com/express/", 
        "https://www.adobe.com/express/feature/image/remove-background",
        "https://www.adobe.com/express/create/flyer",
        "https://www.adobe.com/express/create/banner",
        "https://www.adobe.com/express/discover/messages/card/birthday/mother",
        "https://www.adobe.com/express/thisandthat2"), url, "other") AS url,
    MAX(weight) AS weight,
    MAX(time) AS last,
    MIN(time) AS first
FROM `helix-225321.helix_rum.rum202109` 
WHERE 
    generation IS NOT NULL
    AND CAST(time AS STRING) > CAST(UNIX_MICROS(TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 12 HOUR)) AS STRING)
GROUP BY id, generation, url),
results AS (
SELECT 
    SUM(weight) AS pageviews,
    IF((MAX(last) - MIN(first)) / 1000 / 3600 > 0, ROUND(SUM(weight) / ((MAX(last) - MIN(first)) / 1000 / 3600)), 0) AS pageviews_per_hour,
    (MAX(last) - MIN(first)) / 1000 / 3600 AS hours,
    url,
    generation
FROM by_generation
GROUP BY generation, url
ORDER BY pageviews_per_hour
)

SELECT * FROM results
@trieloff trieloff added the enhancement New feature or request label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant