Skip to content

Commit 87dc594

Browse files
author
DanielRyanSmith
committed
update gcp query
1 parent 316e924 commit 87dc594

File tree

1 file changed

+32
-45
lines changed

1 file changed

+32
-45
lines changed

lib/gcpspanner/missing_one_implementation.go

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -137,47 +137,9 @@ LIMIT
137137
`
138138

139139
const gcpMissingOneImplCountRawTemplate = `
140-
WITH UnsupportedFeatures AS (
141-
SELECT DISTINCT
142-
bfse1.WebFeatureID,
143-
bfse1.EventReleaseDate
144-
FROM
145-
BrowserFeatureSupportEvents bfse1
146-
{{ .BrowserSupportedFeaturesFilter }}
147-
{{ .ExcludedFeatureFilter }}
148-
),
149-
OtherSupportedFeatures AS (
150-
SELECT
151-
bfse_other.WebFeatureID,
152-
bfse_other.EventReleaseDate
153-
FROM
154-
BrowserFeatureSupportEvents bfse_other
155-
WHERE
156-
bfse_other.SupportStatus = 'supported'
157-
AND bfse_other.TargetBrowserName IN UNNEST(@otherBrowserNames)
158-
{{ .OtherExcludedFeatureFilter }}
159-
GROUP BY
160-
bfse_other.WebFeatureID, bfse_other.EventReleaseDate
161-
HAVING
162-
-- Ensures all other browsers support the feature.
163-
COUNT(DISTINCT bfse_other.TargetBrowserName) = @numOtherBrowsers
164-
),
165-
AggregatedCounts AS (
166-
SELECT
167-
uf.EventReleaseDate,
168-
COUNT(uf.WebFeatureID) AS FeatureCount
169-
FROM
170-
UnsupportedFeatures uf
171-
JOIN
172-
OtherSupportedFeatures osf
173-
ON uf.WebFeatureID = osf.WebFeatureID
174-
AND uf.EventReleaseDate = osf.EventReleaseDate
175-
GROUP BY
176-
uf.EventReleaseDate
177-
)
178140
SELECT
179141
r.EventReleaseDate,
180-
COALESCE(ac.FeatureCount, 0) AS Count
142+
COALESCE(AggregatedCounts.FeatureCount, 0) AS Count
181143
FROM (
182144
SELECT DISTINCT
183145
ReleaseDate AS EventReleaseDate
@@ -187,13 +149,38 @@ FROM (
187149
BrowserName IN UNNEST(@allBrowserNames)
188150
AND ReleaseDate >= @startAt
189151
AND ReleaseDate < @endAt
190-
{{if .ReleaseDateParam }}
191-
AND ReleaseDate < @{{ .ReleaseDateParam }}
192-
{{end}}
193-
AND ReleaseDate < CURRENT_TIMESTAMP()
194152
) r
195-
LEFT JOIN
196-
AggregatedCounts ac ON r.EventReleaseDate = ac.EventReleaseDate
153+
LEFT JOIN (
154+
SELECT
155+
Unsupported.EventReleaseDate,
156+
COUNT(Unsupported.WebFeatureID) AS FeatureCount
157+
FROM (
158+
SELECT DISTINCT
159+
bfse1.WebFeatureID,
160+
bfse1.EventReleaseDate
161+
FROM
162+
BrowserFeatureSupportEvents bfse1
163+
{{ .BrowserSupportedFeaturesFilter }}
164+
{{ .ExcludedFeatureFilter }}
165+
) Unsupported
166+
JOIN (
167+
SELECT
168+
bfse_other.WebFeatureID,
169+
bfse_other.EventReleaseDate
170+
FROM
171+
BrowserFeatureSupportEvents bfse_other
172+
WHERE
173+
bfse_other.SupportStatus = 'supported'
174+
AND bfse_other.TargetBrowserName IN UNNEST(@otherBrowserNames)
175+
GROUP BY
176+
bfse_other.WebFeatureID, bfse_other.EventReleaseDate
177+
HAVING
178+
COUNT(DISTINCT bfse_other.TargetBrowserName) = @numOtherBrowsers
179+
) otherSupported ON Unsupported.WebFeatureID = otherSupported.WebFeatureID
180+
AND Unsupported.EventReleaseDate = otherSupported.EventReleaseDate
181+
GROUP BY
182+
Unsupported.EventReleaseDate
183+
) AggregatedCounts ON r.EventReleaseDate = AggregatedCounts.EventReleaseDate
197184
ORDER BY
198185
r.EventReleaseDate DESC
199186
LIMIT

0 commit comments

Comments
 (0)