-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page Weight API #10
Comments
QueryCREATE TEMPORARY FUNCTION GET_PAGE_WEIGHT(
records ARRAY<STRUCT<
client STRING,
total INT64,
js INT64,
images INT64
>>
) RETURNS ARRAY<STRUCT<
name STRING,
mobile STRUCT<
median_bytes INT64
>,
desktop STRUCT<
median_bytes INT64
>
>> LANGUAGE js AS '''
const METRICS = ['total', 'js', 'images'];
// Initialize the page weight map.
const pageWeight = Object.fromEntries(METRICS.map(metricName => {
return [metricName, {name: metricName}];
}));
// Populate each client record.
records.forEach(record => {
METRICS.forEach(metricName => {
pageWeight[metricName][record.client] = {median_bytes: record[metricName]};
});
});
return Object.values(pageWeight);
''';
SELECT
date,
app AS technology,
rank,
geo,
GET_PAGE_WEIGHT(ARRAY_AGG(STRUCT(
client,
median_bytes_total,
median_bytes_js,
median_bytes_image
))) AS pageWeight
FROM
`httparchive.core_web_vitals.technologies`
WHERE
date = '2023-07-01'
GROUP BY
date,
app,
rank,
geo Example record[{
"date": "2023-07-01",
"technology": "WordPress",
"rank": "ALL",
"geo": "ALL",
"pageWeight": [{
"name": "total",
"mobile": {
"median_bytes": "2231859"
},
"desktop": {
"median_bytes": "2600099"
}
}, {
"name": "js",
"mobile": {
"median_bytes": "563278"
},
"desktop": {
"median_bytes": "652651"
}
}, {
"name": "images",
"mobile": {
"median_bytes": "890780"
},
"desktop": {
"median_bytes": "1048110"
}
}]
}] |
The endpoint was added to the API see docs https://github.com/HTTPArchive/tech-report-apis/blob/main/README.md#get-page-weight Working on the Data script |
@maceto could you format the data the same as the other endpoints? Current behaviorCurrently it returns the data the same as in the JSON files:
Desired behaviorSomething similar to the other endpoints, see for example: #4 Example format:
|
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: