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: show overall category scores in csv output #11404

Merged
merged 3 commits into from
Sep 11, 2020

Conversation

pujitha7
Copy link
Contributor

@pujitha7 pujitha7 commented Sep 10, 2020

closes #11398
Summary
Added one row each for category to show overall category score in the output CSV report

@pujitha7 pujitha7 requested a review from a team as a code owner September 10, 2020 15:44
@pujitha7 pujitha7 requested review from brendankenny and removed request for a team September 10, 2020 15:44
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@pujitha7
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

thanks @pujitha7 this is great!

Comment on lines 76 to 78
const overallCategoryScore = category.score === null ? -1 : category.score;
rows.push(rowFormatter([lhr.requestedUrl, lhr.finalUrl, category.title,
'overall-category-score', 'Overall Category Score', 'numeric', overallCategoryScore]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

WDYT about including the category in these column values? something like the below

Suggested change
const overallCategoryScore = category.score === null ? -1 : category.score;
rows.push(rowFormatter([lhr.requestedUrl, lhr.finalUrl, category.title,
'overall-category-score', 'Overall Category Score', 'numeric', overallCategoryScore]));
const table = Object.keys(lhr.categories).map(categoryId => {
const rows = [];
const category = lhr.categories[categoryId];
const overallCategoryScore = category.score === null ? -1 : category.score;
rows.push(rowFormatter([lhr.requestedUrl, lhr.finalUrl, category.title,
'${categoryId}-score', `${category.title} Category Score`, 'numeric', overallCategoryScore]));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it would be more readable. I will make these changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, no we definitely don't need to iterate both. GitHub wouldn't allow a multi-line suggestion so this would absolutely replace the Object.values iteration (we pull in the value with const category = lhr.categories[categoryId]; here anyway).

Does that make sense?

Copy link
Contributor Author

@pujitha7 pujitha7 Sep 10, 2020

Choose a reason for hiding this comment

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

Yeah it made sense a little later so deleted the comment. I modified the code. Please review

@@ -104,7 +104,7 @@ describe('ReportGenerator', () => {
expect(lines.length).toBeGreaterThan(100);
expect(lines.slice(0, 2).join('\n')).toMatchInlineSnapshot(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's use the first 3 lines now to test both category and audit lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes sure

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM aside from the test fix, thanks @pujitha7!

Comment on lines 123 to 127
csvOutput.includes('performance-score');
csvOutput.includes('accessibility-score');
csvOutput.includes('best-practices-score');
csvOutput.includes('seo-score');
csvOutput.includes('pwa-score');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
csvOutput.includes('performance-score');
csvOutput.includes('accessibility-score');
csvOutput.includes('best-practices-score');
csvOutput.includes('seo-score');
csvOutput.includes('pwa-score');
expect(csvOutput).toContain('performance-score');
expect(csvOutput).toContain('accessibility-score');
expect(csvOutput).toContain('best-practices-score');
expect(csvOutput).toContain('seo-score');
expect(csvOutput).toContain('pwa-score');

Copy link
Collaborator

Choose a reason for hiding this comment

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

currently it's not actually asserting :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah i missed that

@patrickhulce
Copy link
Collaborator

thanks @pujitha7! 🎉 great job here :)

@patrickhulce patrickhulce merged commit a1571ba into GoogleChrome:master Sep 11, 2020
zhangpeidong-peyton pushed a commit to zhangpeidong-peyton/lighthouse that referenced this pull request Sep 14, 2020
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.

Include category score in CSV output
5 participants