|
1 | 1 | CREATE OR REPLACE VIEW
|
2 | 2 | `moz-fx-data-shared-prod.app_store.firefox_app_store_territory_source_type_report`
|
3 | 3 | AS
|
4 |
| --- https://developer.apple.com/help/app-store-connect/view-sales-and-trends/download-and-view-reports |
5 |
| --- "Time zone: Reports are based on Pacific Time (PT). A day includes transactions that happened from 12:00 a.m. to 11:59 p.m. PT. |
6 | 4 | SELECT
|
7 |
| - -- However, this timestamp appear to always show midnight meaning if we do timezone conversion |
8 |
| - -- we will end up moving all results 1 day back if we attempt conversion to UTC. |
9 |
| - DATE(`date`) AS `date`, |
10 |
| - app_id, |
11 |
| - CAST(NULL AS STRING) AS app_name, |
12 |
| - source_type, |
13 |
| - territory, |
14 |
| - impressions, |
15 |
| - impressions_unique_device, |
16 |
| - page_views, |
17 |
| - page_views_unique_device, |
18 |
| - -- These fields did not exist in the previous version. |
19 |
| - CAST(NULL AS INTEGER) AS first_time_downloads, |
20 |
| - CAST(NULL AS INTEGER) AS redownloads, |
21 |
| - CAST(NULL AS INTEGER) AS total_downloads, |
| 5 | + -- https://developer.apple.com/help/app-store-connect/view-sales-and-trends/download-and-view-reports |
| 6 | + -- "Time zone: Reports are based on Pacific Time (PT). A day includes transactions that happened from 12:00 a.m. to 11:59 p.m. PT." |
| 7 | + -- Date conversion in the query is required to unify the dates to UTC timezone which is what we use. |
| 8 | + * REPLACE (TIMESTAMP(DATETIME(`date`, "America/Los_Angeles")) AS `date`), |
| 9 | + `date` AS date_pst, |
22 | 10 | FROM
|
23 | 11 | `moz-fx-data-shared-prod.app_store_syndicate.app_store_territory_source_type_report`
|
24 |
| -WHERE |
25 |
| - `date` < "2024-01-01" |
26 |
| -UNION ALL |
27 |
| --- New connector's data. The schema is a bit different and the new one includes additional metrics: |
28 |
| --- first_time_downloads, redownloads, and total_downloads. |
29 |
| -SELECT |
30 |
| - date_day AS `date`, |
31 |
| - app_id, |
32 |
| - app_name, |
33 |
| - source_type, |
34 |
| - territory_long AS territory, |
35 |
| - impressions, |
36 |
| - impressions_unique_device, |
37 |
| - page_views, |
38 |
| - page_views_unique_device, |
39 |
| - first_time_downloads, |
40 |
| - redownloads, |
41 |
| - total_downloads, |
42 |
| -FROM |
43 |
| - `moz-fx-data-bq-fivetran.firefox_app_store_v2_apple_store.apple_store__territory_report` |
44 |
| -WHERE |
45 |
| - date_day >= "2024-01-01" |
0 commit comments