Skip to content

Commit

Permalink
add cs mapping to domains
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiapuric committed Apr 18, 2024
1 parent f66e214 commit f13ac4e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/queries/dash/domain-list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

WITH pvs AS (
SELECT
host,
SUM(pageviews) AS pageviews,
REGEXP_REPLACE(hostname, r'^www.', '') AS hostname,
FORMAT_DATE('%Y-%b', time) AS month,
Expand Down Expand Up @@ -41,7 +42,16 @@ WITH pvs AS (
AND hostname NOT LIKE '%.edison.pfizer' -- not live
AND hostname NOT LIKE '%.web.pfizer'
OR hostname = 'www.hlx.live'
GROUP BY month, hostname
GROUP BY month, host, hostname
),

cs AS (
SELECT
hostname,
REGEXP_EXTRACT(host, r'^publish-p([0-9]+)') AS program_id,
REGEXP_EXTRACT(host, r'^publish-p[0-9]+-e([0-9]+)') AS environment_id
FROM pvs
WHERE REGEXP_CONTAINS(host, r'^publish-p[0-9]+-e[0-9]+')
),

total_pvs AS (
Expand All @@ -59,15 +69,15 @@ domains AS (
a.hostname,
a.first_visit,
a.last_visit,
b.pageviews AS current_month_visits,
a.estimated_pvs AS total_visits
SUM(b.pageviews) AS current_month_visits,
SUM(a.estimated_pvs) AS total_visits
FROM total_pvs AS a
LEFT JOIN
pvs AS b
ON
a.hostname = b.hostname AND b.month = FORMAT_DATE('%Y-%b', CURRENT_DATE())
GROUP BY
a.hostname, a.first_visit, a.last_visit, a.estimated_pvs, b.pageviews
a.hostname, a.first_visit, a.last_visit
)

SELECT
Expand All @@ -76,12 +86,15 @@ SELECT
a.first_visit,
a.last_visit,
a.current_month_visits,
a.total_visits
a.total_visits,
CAST(cs.program_id AS INT64) AS program_id,
CAST(cs.environment_id AS INT64) AS environment_id
FROM domains AS a
LEFT JOIN
helix_reporting.domain_info AS b
ON
a.hostname = b.domain
LEFT JOIN cs ON a.hostname = cs.hostname
WHERE
a.total_visits >= 1000
AND DATE(a.last_visit) > (CURRENT_DATE() - 60)
Expand Down

0 comments on commit f13ac4e

Please sign in to comment.