Simplify GLAM template for getting latest versions (#3880)

* Simplify GLAM latest version template

* Use buildhub2 table instead

---------

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Linh Nguyen 2023-06-05 10:23:21 -04:00 коммит произвёл GitHub
Родитель 5330dd19da
Коммит 8ad45a0592
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 37 удалений

Просмотреть файл

@ -28,6 +28,16 @@ class TemplateResult:
query_text: str
APP_PREFIX_CHANNELS = {
"firefox_desktop_glam_nightly": "nightly",
"firefox_desktop_glam_beta": "beta",
"firefox_desktop_glam_release": "release",
"org_mozilla_fenix_glam_nightly": "nightly",
"org_mozilla_fenix_glam_beta": "beta",
"org_mozilla_fenix_glam_release": "release",
}
def from_template(
query_type: QueryType,
template_name: str,
@ -213,11 +223,7 @@ def main():
[
table(
"latest_versions_v1",
**dict(
source_table=(
f"glam_etl.{args.prefix}__view_clients_daily_scalar_aggregates_v1"
)
),
**dict(app_id_channel=(f"'{APP_PREFIX_CHANNELS[args.prefix]}'")),
),
init(
"clients_scalar_aggregates_v1",

Просмотреть файл

@ -1,36 +1,12 @@
{{ header }}
WITH extracted AS (
SELECT
client_id,
channel,
app_version
FROM
{{ source_table }}
WHERE
submission_date
BETWEEN DATE_SUB(@submission_date, INTERVAL 28 DAY)
AND @submission_date
AND channel IS NOT NULL
),
transformed AS (
SELECT
channel,
app_version
FROM
extracted
GROUP BY
channel,
app_version
HAVING
COUNT(DISTINCT client_id) > 5
ORDER BY
channel,
app_version DESC
)
SELECT
channel,
MAX(app_version) AS latest_version
build.`target`.channel AS channel,
MAX(mozfun.norm.extract_version(build.`target`.version,
'major')) AS latest_version
FROM
transformed
`moz-fx-data-shared-prod.telemetry.buildhub2`
WHERE
build.`source`.product = "firefox"
AND build.`target`.channel = {{ app_id_channel }}
GROUP BY
channel
build.`target`.channel