diff --git a/package.json b/package.json index f8d943b3..f266cac9 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,10 @@ "src/queries/rum-targets.sql", "src/queries/dash/auth-all-domains.sql", "src/queries/dash/domain-list.sql", - "src/queries/dash/update-domain-info.sql" + "src/queries/dash/update-domain-info.sql", + "src/queries/dash/pageviews.sql", + "src/queries/dash/github-commits.sql" + ] }, "nodemonConfig": { diff --git a/src/queries/dash/github-commits.sql b/src/queries/dash/github-commits.sql new file mode 100644 index 00000000..eb5dda1f --- /dev/null +++ b/src/queries/dash/github-commits.sql @@ -0,0 +1,40 @@ +--- description: Get Daily Commits For a Site or Repo +--- Authorization: none +--- Access-Control-Allow-Origin: * +--- limit: 30 +--- interval: 30 +--- offset: 0 +--- startdate: 2023-02-01 +--- enddate: 2023-05-28 +--- timezone: UTC +--- timeunit: day +--- exactmatch: false +--- url: - +--- device: all +--- domainkey: secret +WITH current_data AS ( + SELECT * + FROM + `HELIX-225321.HELIX_EXTERNAL_DATA.DAILY_COMMITS`( + @url, + @offset, + @interval, + @startdate, + @enddate, + @domainkey + ) +) + +SELECT * FROM current_data WHERE + NOT user = 'GitHub' + AND NOT user = 'GitHub Action' + AND NOT user = 'GitHub Enterprise' + AND NOT user = 'CircleCi Build' + AND NOT user = 'Helix Bot' + AND NOT user = 'adobe-alloy-bot' + AND NOT user = 'github-actions' + AND NOT user = 'github-actions[bot]' + AND NOT user = 'helix-bot[bot]' + AND NOT user = 'renovate[bot]' + AND NOT user = 'semantic-release-bot' +ORDER BY owner_repo ASC, commit_date ASC diff --git a/src/queries/dash/pageviews.sql b/src/queries/dash/pageviews.sql new file mode 100644 index 00000000..35f6e596 --- /dev/null +++ b/src/queries/dash/pageviews.sql @@ -0,0 +1,30 @@ +--- 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: - +--- device: all +--- domainkey: secret +WITH pageviews_by_id AS ( + SELECT + hostname, + id, + MAX(weight) AS pageviews + FROM + `helix-225321.helix_rum.EVENTS_V4`( + net.host(@url), @offset, @interval, '-', '-', 'UTC', 'all', @domainkey + ) + GROUP BY id, hostname +) + +SELECT + hostname, + SUM(pageviews) AS pageviews +FROM pageviews_by_id +GROUP BY hostname +ORDER BY pageviews DESC diff --git a/src/queries/rum-pageviews.sql b/src/queries/rum-pageviews.sql index 97ca369c..ae5103af 100644 --- a/src/queries/rum-pageviews.sql +++ b/src/queries/rum-pageviews.sql @@ -37,7 +37,7 @@ BEGIN WHEN 365 THEN TIMESTAMP_TRUNC(time, YEAR) ELSE TIMESTAMP_TRUNC(time, DAY) END AS date - FROM helix_rum.PAGEVIEWS_V3( + FROM helix_rum.PAGEVIEWS_V4( inurl, # url (inoffset * ingranularity) - 1, # offset inlimit * ingranularity, # days to fetch