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

✨ Add filter information to readme and metadata #4229

Merged
merged 7 commits into from
Dec 13, 2024

Conversation

danyx23
Copy link
Contributor

@danyx23 danyx23 commented Nov 28, 2024

When using the download API, add information about active filters to the metadata and readme.

Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

If you fix the TypeError this is good to go. I'll leave it up to you (and lars?) to make the call re: whitelisting.

// delete url query params that the download api uses but that are not related to grapher
delete params.v1
delete params.csvType
delete params.useColumnShortNames
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth the extra effort to use a whitelist here (and in the creation of urlWithFilters) ? Otherwise you can add arbitrary text to the query string and get a readme that says whatever anyone wants.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! It means that when we do this for MDims we'll have to expand the whitelist but it's probably the better way to do things.

@@ -0,0 +1,12 @@
export function getGrapherFilters(
searchParams: URLSearchParams
): Record<string, unknown> {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's actually not possible to get anything but a string as one of the values here.

yield `### Active Filters`
yield ""
yield `A filtered subset of the full data was downloaded. The following filters were applied:`
for (const entry of Object.entries(filterSettings)) {
Copy link
Member

Choose a reason for hiding this comment

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

If getGrapherFilters was typed with Record<string, string> then you could do the sugary thing of

for (const [key, val] of Object.entries(filterSettings)) {

which is 100% absolutely completely not necessary. I'm just sharing coz I think it's neat 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, this is nicer :)

@danyx23 danyx23 merged commit ef7505a into master Dec 13, 2024
2 of 5 checks passed
@danyx23 danyx23 deleted the download-api-add-filter-information branch December 13, 2024 18:53
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.

2 participants