Skip to content
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

report: sort audits by weight #13053

Merged
merged 6 commits into from
Oct 27, 2021
Merged

report: sort audits by weight #13053

merged 6 commits into from
Oct 27, 2021

Conversation

connorjclark
Copy link
Collaborator

Sort auditRefs by weight to influence render order in report.

Maybe useful diff in auditRefs order: https://www.diffchecker.com/NmdJHTbN

ref #12996

@connorjclark connorjclark requested a review from a team as a code owner September 13, 2021 22:38
@connorjclark connorjclark requested review from adamraine and removed request for a team September 13, 2021 22:38
@google-cla google-cla bot added the cla: yes label Sep 13, 2021
@@ -138,6 +138,10 @@ export class Util {
});
}
});

category.auditRefs.sort((a, b) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be a better fit in the category renderer since we're really using it for rendering side effects. That might(?) also allow easier splitting on category type, since it seems like we shouldn't be doing this for the perf category, at least

Copy link
Collaborator Author

@connorjclark connorjclark Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hadn't realized it changed the order of the metrics in the metric table. But the new order seems fine? is there any intention behind the current order?

this might be a better fit in the category renderer

for (const [clumpId, auditRefs] of clumps) {

a) make a new array here const auditRefsByWeight = [...auditRefs].sort(...),
b) or mutate the array (mutating was the only thing I had considered, which is why I thought to do it in the only place we mutate the LHR)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a new array here const auditRefsByWeight = [...auditRefs].sort(...),

this one sounds good to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hadn't realized it changed the order of the metrics in the metric table. But the new order seems fine? is there any intention behind the current order?

I believe there is an intentional order (or maybe there was an intentional order and we've organically evolved since then?), but we also don't necessarily want to rearrange things on people (at least in a minor release) since you get pretty used to the metric order

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v9 then?

at the moment, LCP isn't even next to FCP... + things aren't sorted by weight ... so no idea if there is any logical framework to the order right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(aside from my above comments.. i think this definitely improves the accessibility category) 👍

Copy link
Member

@brendankenny brendankenny Sep 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connorjclark added the 9.0 label yesterday

If we don't change the perf audit ordering (which I (personally) don't think we should do anyways), I think it'd be fine to ship sorting the accessibility, etc audits without a breaking change. It's definitely an improvement and not a disruptive one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont care too much about placement.. this location also seems fine.

I really think it should be in category-renderer:

It's category rendering, not preparing data for compatibility. If you go looking for what's ordering audits in a category in the report, the most logical place is in CategoryRenderer.render() (or LHR generation, but agreed with #13053 (comment)). It's easy to unit test that way. We get abstaining from performance category renderer changes automatically. win-win-win-win :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it would parallel the equivalent functionality in performanceCategoryRenderer for opportunities

const opportunityAudits = category.auditRefs
.filter(audit => audit.group === 'load-opportunities' && !Util.showAsPassed(audit.result))
.sort((auditA, auditB) => this._getWastedMs(auditB) - this._getWastedMs(auditA));

and diagnostics

const diagnosticAudits = category.auditRefs
.filter(audit => audit.group === 'diagnostics' && !Util.showAsPassed(audit.result))
.sort((a, b) => {
const scoreA = a.result.scoreDisplayMode === 'informative' ? 100 : Number(a.result.score);
const scoreB = b.result.scoreDisplayMode === 'informative' ? 100 : Number(b.result.score);
return scoreA - scoreB;
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I just haven't gotten around to it yet.

@connorjclark
Copy link
Collaborator Author

Oh, and I chose to sort in the report to 1) fix all rendering all previous LHRs 2) we don't necessarily want to sort audit refs in the default config

report/renderer/category-renderer.js Outdated Show resolved Hide resolved
report/renderer/category-renderer.js Outdated Show resolved Hide resolved
@connorjclark connorjclark merged commit cbdcab1 into master Oct 27, 2021
@connorjclark connorjclark deleted the report-order-weight branch October 27, 2021 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants