Skip to content

Commit 1a3c0e6

Browse files
committed
feat: remove app_name from usage_reporting_clients_first_seen_v1 and add a note to last_seen
1 parent 7b9416f commit 1a3c0e6

3 files changed

+20
-4
lines changed

sql_generators/usage_reporting/templates/usage_reporting_clients_first_seen_v1.query.sql.jinja

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ WITH
1010
@submission_date AS first_seen_date,
1111
{% endif %}
1212
{% endraw %}
13+
{% if app_name == "firefox_desktop" %}
1314
app_channel,
15+
{% endif %}
1416
FROM
1517
`{{ project_id }}.{{ channel_dataset }}.usage_reporting_clients_daily`
1618
WHERE
@@ -23,13 +25,17 @@ WITH
2325
{% endif %}
2426
{% endraw %}
2527
GROUP BY
26-
usage_profile_id,
27-
app_channel
28+
usage_profile_id
29+
{% if app_name == "firefox_desktop" %}
30+
, app_channel
31+
{% endif %}
2832
),
2933
_previous AS (
3034
SELECT
3135
usage_profile_id,
32-
app_channel,
36+
{% if app_name == "firefox_desktop" %}
37+
app_channel,
38+
{% endif %}
3339
FROM
3440
`{{ project_id }}.{{ channel_dataset }}_derived.{{ view_name }}_v1`
3541
WHERE
@@ -45,12 +51,16 @@ _previous AS (
4551
SELECT
4652
first_seen_date,
4753
usage_profile_id,
54+
{% if app_name == "firefox_desktop" %}
55+
-- app_channel is only needed on desktop as the single namespace
56+
-- contains data for all channel unlike the mobile apps.
4857
app_channel,
58+
{% endif %}
4959
FROM
5060
_current
5161
LEFT JOIN
5262
_previous
53-
USING (usage_profile_id, app_channel)
63+
USING (usage_profile_id {% if app_name == "firefox_desktop" %}, app_channel{% endif %})
5464
WHERE
5565
_previous.usage_profile_id IS NULL
5666
QUALIFY

sql_generators/usage_reporting/templates/usage_reporting_clients_first_seen_v1.schema.yaml.jinja

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ fields:
1212
description: |
1313
A UUID of the usage_profile.
1414

15+
{% if app_name == "firefox_desktop" %}
16+
# app_channel is only needed on desktop as the single namespace
17+
# contains data for all channel unlike the mobile apps.
1518
- mode: NULLABLE
1619
name: app_channel
1720
type: STRING
1821
description: |
1922
The channel the application is being distributed on.
23+
{% endif %}

sql_generators/usage_reporting/templates/usage_reporting_clients_last_seen_v1.query.sql.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ FROM
5151
_current
5252
FULL JOIN
5353
_previous
54+
-- TODO: should we be using app_channel for join here?
55+
-- or are we 100% confident usage_profile_id will always be unique across channels?
5456
USING (usage_profile_id)

0 commit comments

Comments
 (0)