-
-
Notifications
You must be signed in to change notification settings - Fork 627
feat(sustainable) : added countryCode option for country specific CO₂ calculations #4583
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
base: main
Are you sure you want to change the base?
Changes from all commits
a250f6a
dcab3b2
c224252
bc03f9c
f136f00
8f22898
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,16 @@ export default class SustainablePlugin extends SitespeedioPlugin { | |
| super({ name: 'sustainable', options, context, queue }); | ||
| } | ||
|
|
||
| static getCliOptions() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work? I think the options for now could be moved to lib/cli/cli.js where the rest of the sustainable options is today, to keep it consistent.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works I have tested it locally switching between two different country codes shows different result in different CO2 values and I will move and test it on cli.js to ensure consistency and get back to you shorty |
||
| return { | ||
| 'sustainable.countryCode': { | ||
| describe: | ||
| 'ISO driven country code used to calculate country specific carbon intensity via electricity-maps', | ||
| type: 'string' | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| async open(context, options) { | ||
| this.storageManager = context.storageManager; | ||
| this.options = options; | ||
|
|
@@ -162,6 +172,9 @@ export default class SustainablePlugin extends SitespeedioPlugin { | |
| if (this.sustainableOptions.model === 'swd') { | ||
| configuration.version = this.sustainableOptions.modelVersion; | ||
| } | ||
| if (this.sustainableOptions.countryCode) { | ||
| configuration.countryCode = this.sustainableOptions.countryCode; | ||
| } | ||
| const CO2 = new co2(configuration); | ||
| const co2PerDomain = perDomain(message.data, hostingGreenCheck, CO2); | ||
| const baseDomain = message.data.baseDomain; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the rest of the documentation we use
--sustainable.enable, I think we should use that here too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense I can update the result page to also show which countryCode was used, so it’s clear what configuration the CO₂ calculation is based on and for documentation I will make a update shortly.