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

Set COVIDcast export values based on URL parameters #1244

Merged
merged 7 commits into from
May 13, 2024
Merged

Conversation

rzats
Copy link
Contributor

@rzats rzats commented Mar 14, 2024

Prerequisites:

  • Unless it is a hotfix it should be merged against the dev branch
  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

Summary

Fills in the form values on the COVIDcast Export Data page based on URL parameters. This will be used to integrate the export UI with e.g. the EpiVis dashboard or signal documentation, with certain values being pre-filled based on parameters selected on another section of the website.

To test this out, visit the export dashboard on the preview website, then append this set of parameters to the URL:

/?data_source=covid-act-now&signal=covid-act-now-pcr_specimen_total_tests&start_day=2024-01-01&end_day=2024-02-02&geo_type=state

@rzats rzats changed the title Rzatserkovnyi/export Set COVIDcast export values based on URL parameters Mar 14, 2024
Copy link

netlify bot commented Mar 14, 2024

Preview link ready!

Name Link
🔨 Latest commit 333a79c
🔍 Latest deploy log https://app.netlify.com/sites/cmu-delphi-covidcast/deploys/66043c392577910008596279
😎 Deploy Preview https://deploy-preview-1244--cmu-delphi-covidcast.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rzats rzats requested a review from melange396 March 15, 2024 15:02
Copy link
Contributor

@melange396 melange396 left a comment

Choose a reason for hiding this comment

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

Not bad so far!

@melange396
Copy link
Contributor

clarification: the dates in the url and in the page seem to be off by one for me --
image

@rzats
Copy link
Contributor Author

rzats commented Mar 20, 2024

Notes from the meeting:

@rzats
Copy link
Contributor Author

rzats commented Mar 27, 2024

@melange396 fixed up all your suggestions (except the API key to allow access to restricted signals - I think that's best done in a separate PR, since it's not really related to URL params)

Here's a new URL to test out the fix to the issue you've mentioned:
https://deploy-preview-1244--cmu-delphi-covidcast.netlify.app/export/?data_source=covid-act-now&signal=covid-act-now-pcr_specimen_total_tests&start_day=2024-01-01&end_day=2024-02-02&geo_type=state

In short - this was a bug with inactive sensors in particular, where the datetime selector was incorrectly set to current (e.g. 2024) dates for inactive sensors (so e.g. only running between 2020-2021). It was possible to reset the dates to valid ones by re-selecting the date on the picker, but a bit unintuitive.

I fixed this by setting the datetime selector to the sensor's minimum and maximum start time, if it's inactive.

@rzats rzats requested a review from melange396 March 27, 2024 14:25
@melange396
Copy link
Contributor

Start date field is still showing off-by-one problem, end date field looks like its bound to the metadata (even though specified date is inside the valid range):
image

@@ -27,18 +27,55 @@
}
}

// Pre-fill the form from URL parameters.
// Supported parameters: source, sensor, start, end, geo_type, geo_id
Copy link
Contributor

Choose a reason for hiding this comment

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

change these to match new parameter names

Comment on lines +107 to +108
// Populate region based on URL params... but let the user override this later
if (urlParams.has('geo_value') && !geoURLSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it remove the need for geoURLSet if we put this outside of the $: {} block?

}
if (
urlParams.has('end_day') &&
new Date(urlParams.get('end_day')) <= sensor.meta.minTime &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
new Date(urlParams.get('end_day')) <= sensor.meta.minTime &&
new Date(urlParams.get('end_day')) >= sensor.meta.minTime &&

if (sensor && !sensor.active) {
// If the sensor is inactive, set the start and end dates to its historical range rather than current date
if (
urlParams.has('start_day') &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Im not sure we want to clamp these values to the active range if theyve been specified in the URL... The principle of least surprise suggests showing the user what they asked for.

Copy link
Contributor

@dshemetov dshemetov left a comment

Choose a reason for hiding this comment

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

This looks good enough to merge to me. Since this feature will have a "silent" release for now and none of the changes are hard to revert or modify, we can keep iterating on it live.

After syncing with Rostyslav on Slack and trying out some features out in the browser, we have a list of a few outstanding issues that Rostyslav will address in the next PR:

  • geo_value=CA is allowed, but geo_value=ca causes the page to hang; this is the opposite of the API behavior and needs a workaround (like dynamically lower-casing or upper-casing as needed)
  • when browsing on the dashboard, the URL parameters I noticed were sensor, region, and date; we will need to convert sensor into data_source and signal (should be doable with a split on "-"), region into geo_value and date into start_date / end_date

Let's make sure those tasks are captured in whatever issue is tracking this work.

Comment on lines +58 to +60
// Also normalize the dates to the current timezone
startDate = new Date(startDate.getTime() - startDate.getTimezoneOffset() * -60000);
endDate = new Date(endDate.getTime() - endDate.getTimezoneOffset() * -60000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a comment about the Javascript string parsing + negative timezone edge cases here. If this is a common fix, maybe we can include a link instead of writing the full explanation out.

@rzats rzats requested a review from melange396 May 13, 2024 21:11
@rzats rzats merged commit d98c513 into dev May 13, 2024
6 checks passed
@rzats rzats deleted the rzatserkovnyi/export branch May 13, 2024 21:17
@melange396
Copy link
Contributor

Why was this merged? There are still unaddressed concerns, plus there is no reason to release bugged and undertested functionality.

@dshemetov
Copy link
Contributor

I thought Rostyslav addressed most of the concerns from your previous review? My personal preference here is to not let the perfect be the enemy of the good. Rostyslav made an issue on Jira to track TODOs on this feature.

@dshemetov
Copy link
Contributor

But as a broader point, I'm not clear about our approval process for these PRs. In general, Rostyslav, we should probably wait for George's input, even if I give a more recent review. I'm writing my reviews from my personal perspective on the issue, but I'd like to give George the opportunity to give his take. I'm a bit out of the loop on things on the front-end / dev side, always happy to give input and take some burden off of George, but I do think that George has a better view on what needs to get done and when things are ready to merge.

@rzats
Copy link
Contributor Author

rzats commented May 15, 2024

Things to fix up:

  • geoURLSet - try bringing it out of the $ block so it only runs once
  • geo_value - convert it to uppercase internally
  • Add code comment about timezone conversions, especially explain the weird double negative

@dshemetov
Copy link
Contributor

Also this one:

  • when browsing on the dashboard, the URL parameters I noticed were sensor, region, and date; we will need to convert sensor into data_source and signal (should be doable with a split on "-"), region into geo_value and date into start_date / end_date

@melange396 melange396 mentioned this pull request Dec 6, 2024
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.

3 participants