Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Oct 12, 2024
1 parent 55df3c2 commit e28ef8d
Show file tree
Hide file tree
Showing 16 changed files with 3,728 additions and 129 deletions.
24 changes: 12 additions & 12 deletions definitions/extra/test_env.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const date = constants.currentMonth

var resources_list = [{
datasetId: 'all',
tableId: 'pages'
},
{
datasetId: 'all',
tableId: 'requests'
},
// {datasetId: 'all', tableId: 'parsed_css'},
// {datasetId: 'core_web_vitals', tableId: 'technologies'},
const resources_list = [{
datasetId: 'all',
tableId: 'pages'
},
{
datasetId: 'all',
tableId: 'requests'
}
// {datasetId: 'all', tableId: 'parsed_css'},
// {datasetId: 'core_web_vitals', tableId: 'technologies'},
]

resources_list.forEach(resource => {
Expand All @@ -30,7 +30,7 @@ WHERE date = '${date}'
})

operate('test_table blink_features_dev_dev_usage', {
hasOutput: true,
hasOutput: true
}).queries(`
CREATE SCHEMA IF NOT EXISTS blink_features_dev;
Expand All @@ -41,7 +41,7 @@ WHERE yyyymmdd = '${date}';
`)

operate('test_table blink_features_dev_dev_features', {
hasOutput: true,
hasOutput: true
}).queries(`
CREATE SCHEMA IF NOT EXISTS blink_features_dev;
Expand Down
2 changes: 1 addition & 1 deletion definitions/output/all/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish('pages', {
clusterBy: ['client', 'is_root_page', 'rank'],
requirePartitionFilter: true
},
tags: ['crawl_results_all'],
tags: ['crawl_results_all']
}).preOps(ctx => `
DELETE FROM ${ctx.self()}
WHERE date = '${constants.currentMonth}';
Expand Down
2 changes: 1 addition & 1 deletion definitions/output/all/parsed_css.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish('parsed_css', {
clusterBy: ['client', 'is_root_page', 'rank', 'page'],
requirePartitionFilter: true
},
tags: ['crawl_results_all'],
tags: ['crawl_results_all']
}).preOps(ctx => `
DELETE FROM ${ctx.self()}
WHERE date = '${constants.currentMonth}';
Expand Down
10 changes: 5 additions & 5 deletions definitions/output/all/reprocess_pages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operate(`all_pages_stable_pre`).tags(
operate('all_pages_stable_pre').tags(
['all_pages_stable']
).queries(`
CREATE SCHEMA IF NOT EXISTS all_dev;
Expand Down Expand Up @@ -58,17 +58,17 @@ OPTIONS(
);
`)

const iterations = [],
clients = constants.clients
const iterations = []
const clients = constants.clients

for (
let month = constants.currentMonth;
month >= '2024-09-01'; // 2022-07-01
month = constants.fnPastMonth(month)) {
clients.forEach((client) => {
iterations.push({
month: month,
client: client
month,
client
})
})
}
Expand Down
17 changes: 8 additions & 9 deletions definitions/output/all/reprocess_requests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operate(`all_requests_stable_pre`).tags(
operate('all_requests_stable_pre').tags(
['all_requests_stable']
).queries(`
CREATE SCHEMA IF NOT EXISTS all_dev;
Expand Down Expand Up @@ -36,9 +36,8 @@ OPTIONS(
);
`)

const
iterations = [],
types = ['= "script"', '= "image"', 'NOT IN ("script", "image")']
const iterations = []
const types = ['= "script"', '= "image"', 'NOT IN ("script", "image")']

for (
let month = constants.currentMonth;
Expand All @@ -48,10 +47,10 @@ for (
constants.booleans.forEach((is_root_page) => {
types.forEach((type) => {
iterations.push({
month: month,
client: client,
is_root_page: is_root_page,
type: type
month,
client,
is_root_page,
type
})
})
})
Expand All @@ -62,7 +61,7 @@ iterations.forEach((iteration, i) => {
operate(`all_requests_stable ${iteration.month} ${iteration.client} ${iteration.is_root_page} ${i}`).tags(
['all_requests_stable']
).dependencies([
i === 0 ? 'all_requests_stable_pre' : `all_requests_stable ${iterations[i - 1].month} ${iterations[i - 1].client} ${iterations[i - 1].is_root_page} ${i-1}`
i === 0 ? 'all_requests_stable_pre' : `all_requests_stable ${iterations[i - 1].month} ${iterations[i - 1].client} ${iterations[i - 1].is_root_page} ${i - 1}`
]).queries(ctx => `
DELETE FROM \`all_dev.requests_stable\`
WHERE date = '${iteration.month}'
Expand Down
2 changes: 1 addition & 1 deletion definitions/output/all/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish('requests', {
clusterBy: ['client', 'is_root_page', 'is_main_document', 'type'],
requirePartitionFilter: true
},
tags: ['crawl_results_all'],
tags: ['crawl_results_all']
}).preOps(ctx => `
DELETE FROM ${ctx.self()}
WHERE date = '${constants.currentMonth}';
Expand Down
12 changes: 6 additions & 6 deletions definitions/output/blink_features/usage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
publish("usage", {
schema: "blink_features",
type: "incremental",
publish('usage', {
schema: 'blink_features',
type: 'incremental',
protected: true,
tags: ["blink_features_report"]
tags: ['blink_features_report']
}).preOps(ctx => `
DELETE FROM ${ctx.self()}
WHERE yyyymmdd = REPLACE('${constants.currentMonth}', '-', '');
Expand All @@ -26,7 +26,7 @@ FROM (
type,
COUNT(DISTINCT url) AS num_urls,
ARRAY_AGG(url ORDER BY rank, url LIMIT 100) AS sample_urls
FROM ${ctx.ref("blink_features", "features")}
FROM ${ctx.ref('blink_features', 'features')}
WHERE
yyyymmdd = '${constants.currentMonth}'
${constants.devRankFilter}
Expand All @@ -42,7 +42,7 @@ JOIN (
date,
client,
COUNT(DISTINCT page) AS total_urls
FROM ${ctx.ref("all", "pages")}
FROM ${ctx.ref('all', 'pages')}
WHERE
date = '${constants.currentMonth}' AND
is_root_page = TRUE
Expand Down
8 changes: 4 additions & 4 deletions definitions/output/lighthouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const current_month_underscored = constants.fnDateUnderscored(constants.currentM

constants.clients.forEach(client => {
publish(`${current_month_underscored}_${client}`, {
type: 'table',
schema: 'lighthouse',
tags: ['crawl_results_legacy']
}
type: 'table',
schema: 'lighthouse',
tags: ['crawl_results_legacy']
}
).query(ctx => `
SELECT
page AS url,
Expand Down
8 changes: 4 additions & 4 deletions definitions/output/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const current_month_underscored = constants.fnDateUnderscored(constants.currentM

constants.clients.forEach(client => {
publish(`${current_month_underscored}_${client}`, {
type: 'table',
schema: 'pages',
tags: ['crawl_results_legacy']
}).query(ctx => `
type: 'table',
schema: 'pages',
tags: ['crawl_results_legacy']
}).query(ctx => `
SELECT
page AS url,
payload
Expand Down
8 changes: 4 additions & 4 deletions definitions/output/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const current_month_underscored = constants.fnDateUnderscored(constants.currentM

constants.clients.forEach(client => {
publish(`${current_month_underscored}_${client}`, {
type: 'table',
schema: 'requests',
tags: ['crawl_results_legacy']
}).query(ctx => `
type: 'table',
schema: 'requests',
tags: ['crawl_results_legacy']
}).query(ctx => `
SELECT
page,
url,
Expand Down
10 changes: 5 additions & 5 deletions definitions/sources/declares.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ const staging_tables = ['pages', 'requests', 'parsed_css']
for (const table of staging_tables) {
declare({
schema: 'crawl_staging',
name: table,
name: table
})
}

const crux_tables = ['country_summary', 'device_summary'];
const past_month = constants.fnPastMonth(constants.currentMonth).substring(0, 7).replace('-', '');
const crux_tables = ['country_summary', 'device_summary']
const past_month = constants.fnPastMonth(constants.currentMonth).substring(0, 7).replace('-', '')
for (const table of crux_tables) {
declare({
database: 'chrome-ux-report',
schema: 'materialized',
name: table,
name: table
})

assert(`${table}_not_empty`).query(ctx => `
Expand All @@ -28,5 +28,5 @@ HAVING COUNT(1) = 0
declare({
database: 'chrome-ux-report',
schema: 'experimental',
name: 'global',
name: 'global'
})
40 changes: 20 additions & 20 deletions includes/constants.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const
today = (dataform.projectConfig.vars.today ? dataform.projectConfig.vars.today : new Date().toISOString()).substring(0, 10),
currentMonth = today.substring(0, 8) + "01",
fnDateUnderscored = (date_str) => date_str.replaceAll("-", "_"),
fnPastMonth = (month_ISOstring) => {
let month_date = new Date(month_ISOstring);
month_date.setMonth(month_date.getMonth() - 1)
return month_date.toISOString().substring(0, 10);
},
clients = ['mobile', 'desktop'],
booleans = ['TRUE', 'FALSE'],
[
devTABLESAMPLE,
devRankFilter
] = dataform.projectConfig.vars.env_name == 'dev' ? [
"TABLESAMPLE SYSTEM (0.001 PERCENT)",
"AND rank <= 10000",
true
] : ["", ""]
const today = (dataform.projectConfig.vars.today ? dataform.projectConfig.vars.today : new Date().toISOString()).substring(0, 10)
const currentMonth = today.substring(0, 8) + '01'
const fnDateUnderscored = (date_str) => date_str.replaceAll('-', '_')
const fnPastMonth = (month_ISOstring) => {
const month_date = new Date(month_ISOstring)
month_date.setMonth(month_date.getMonth() - 1)
return month_date.toISOString().substring(0, 10)
}
const clients = ['mobile', 'desktop']
const booleans = ['TRUE', 'FALSE']
const [
devTABLESAMPLE,
devRankFilter
] = dataform.projectConfig.vars.env_name == 'dev'
? [
'TABLESAMPLE SYSTEM (0.001 PERCENT)',
'AND rank <= 10000'
]
: ['', '']

module.exports = {
today,
Expand All @@ -27,4 +27,4 @@ module.exports = {
booleans,
devTABLESAMPLE,
devRankFilter
};
}
Loading

0 comments on commit e28ef8d

Please sign in to comment.