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

adds support for verbose response when checking domains #192

Merged

Conversation

sfishel18
Copy link
Contributor

  • adds a new checkVerbose function to both hosting-node.js and hosting-api.js
  • for checking a single domain, checkVerbose returns the entire payload from the api.thegreenwebfoundation.org endpoint
  • for checking multiple domains, checkVerbose returns a dictionary of each domain mapped to its response payload

Fixes #189

@sfishel18
Copy link
Contributor Author

@fershad / @mrchrisadams here's my initial implementation, let me if this looks like a good direction and if so i'll polish it up and add more test cases

@sfishel18 sfishel18 marked this pull request as draft March 9, 2024 02:49
@sfishel18 sfishel18 force-pushed the support-for-verbose-response branch from 1029367 to 7917327 Compare March 13, 2024 03:25
- adds a new `checkVerbose` function to both hosting-node.js and hosting-api.js
- for checking a single domain, `checkVerbose` returns the entire payload from the api.thegreenwebfoundation.org endpoint
- for checking multiple domains, `checkVerbose` returns a dictionary of each domain mapped to its response payload

Fixes thegreenwebfoundation#189
@sfishel18 sfishel18 force-pushed the support-for-verbose-response branch from 7917327 to ccd5bc1 Compare March 13, 2024 03:31
@sfishel18 sfishel18 marked this pull request as ready for review March 13, 2024 03:36
@sfishel18
Copy link
Contributor Author

@fershad i think this is ready for an initial look from you. i plan to add additional tests for the new code paths, but want to make sure i'm on the right track.

a couple of specific things i wanted your feedback on:

  1. if i understood your comments on the issue, a goal of this is to make the function signatures for the two check functions consistent. i think it's possible to do that without breaking backwards compatibility, by doing introspection of the argument types. but the "overloaded" function signature is a little confusing, so i'd understand if you'd prefer to just go ahead and make a breaking change to the API.

  2. from what i can tell, the local database only contains a list of string domain names, so it doesn't have enough information to return verbose responses. i put in logic to throw an exception if a local database is used in combination with the verbose flag set.

src/hosting-node.js Outdated Show resolved Hide resolved
… instead of optionsOrAgentId and check for option or db
commit 91c1123
Merge: 083e1e7 1c61b98
Author: fershad <[email protected]>
Date:   Sat Apr 6 20:44:00 2024 +0800

    Remove pagexray functions

commit 083e1e7
Author: fershad <[email protected]>
Date:   Sat Apr 6 20:37:00 2024 +0800

    adjust test constants

commit a6f1d4d
Merge: 3756c74 5f46b50
Author: fershad <[email protected]>
Date:   Thu Apr 4 16:04:11 2024 +0800

    Update JSDocs to match behaviour of perVisitType and perByteType

commit 3756c74
Merge: 33dcf5a 1430a1f
Author: fershad <[email protected]>
Date:   Thu Apr 4 16:00:24 2024 +0800

    [AUTOMATED] Update average annual grid intensities

commit 1430a1f
Author: fershad <[email protected]>
Date:   Wed Apr 3 10:10:11 2024 +0000

    Update average annual grid intensities

commit 5f46b50
Author: Matthew Griffin <[email protected]>
Date:   Mon Mar 25 09:26:48 2024 +0000

    Add different type for perVisit results

commit 1c61b98
Author: fershad <[email protected]>
Date:   Sun Mar 17 22:25:45 2024 +0100

    fix hosting test

commit 1e6508a
Author: fershad <[email protected]>
Date:   Sun Mar 17 21:57:22 2024 +0100

    remove pagexray tests

commit 41ee904
Author: fershad <[email protected]>
Date:   Sun Mar 17 21:45:29 2024 +0100

    remove function from hosting-node.js

commit 2a8f601
Author: fershad <[email protected]>
Date:   Sun Mar 17 21:43:08 2024 +0100

    remove pagexray package

commit b2fefd0
Author: fershad <[email protected]>
Date:   Sun Mar 17 21:42:32 2024 +0100

    remove exported functions

commit d6700f5
Author: Matthew Griffin <[email protected]>
Date:   Fri Mar 8 13:29:41 2024 +0000

    Added new JSdoc typedef for components of CO2 estimate
    Added it as a union for return types that can be total or components
src/hosting-node.js Outdated Show resolved Hide resolved
@sfishel18 sfishel18 force-pushed the support-for-verbose-response branch from ad86279 to fe33729 Compare April 14, 2024 16:49
- adds a new `checkVerbose` function to both hosting-node.js and hosting-api.js
- for checking a single domain, `checkVerbose` returns the entire payload from the api.thegreenwebfoundation.org endpoint
- for checking multiple domains, `checkVerbose` returns a dictionary of each domain mapped to its response payload

Fixes thegreenwebfoundation#189
@sfishel18 sfishel18 force-pushed the support-for-verbose-response branch from fe33729 to 031b83c Compare April 14, 2024 16:50
@fershad fershad changed the title adds support for verbose response when chacking domains adds support for verbose response when checking domains Apr 17, 2024
@fershad fershad merged commit d012292 into thegreenwebfoundation:main Apr 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return verbose response for green hosting checks
2 participants