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

Improve handling for URL-based signals & support COVIDcast EpiWeeks #53

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

rzats
Copy link
Contributor

@rzats rzats commented Aug 2, 2024

Closes #43, partially addresses #42:

  • URL-provided signals are given a title in the left-side panel based on their parameters (data source, signals, daily/weekly cadence etc.)
  • Added support for COVIDCast signals with a weekly cadence. This is based on the time_type specified in the meta endpoint, and works for both URL-provided signals as well as those selected in the signal picker.

@@ -34,7 +34,7 @@ export function epiRange(from: string | number, to: string | number): string {

// find the current epiweek and date
const date = new Date();
const epidate = new EpiDate(date.getFullYear() + 1900, date.getMonth() + 1, date.getDate());
const epidate = new EpiDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently epivis makes queries with 3924 set as the end year 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that has been a curious artifact. I'm not sure how it slipped through QA, but it has no real ill effect, and it let us track epivis-based requests to the API servers. It looks like it came from an older piece of javascript where it presumably did the right thing (¯\_(ツ)_/¯). I am leaning towards leaving it as-is until #38 is done (especially so we can see the effect in our logs of more eyes on epivis with the signal discovery app's release). Do you have strong feelings either way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is already done by logging the referrer/origin in the delphi-epidata server? https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/server/_common.py#L70-L71

If we want an even more reliable way to track API requests, a cleaner option is to
(a) start logging a certain custom HTTP header (like Delphi-Api-Origin) in the logging method I linked above;
(b) set that header in EpiVis, and in other apps that we would like to keep track of - like the client, for instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

That server logging would do it if, as cmu-delphi/delphi-epidata#1386 (comment) mentions and #38 references, we update the Referrer-Policy for epivis. Im not suggesting that adding 1900y is "clean", but can we leave it there for now and note that it should come out with #38?

@rzats
Copy link
Contributor Author

rzats commented Aug 2, 2024

As a test for #42, use this link.

#43 can be tested by:

  • selecting Delphi COVIDcast, nchs-mortality, any signal, any state (e.g. "pa") in the signal picker
  • or using this link, which was generated by the Signal Documentation app.

@rzats rzats requested a review from melange396 August 2, 2024 14:49
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.

This is great, and im impressed that you could get it done with this small of a diff!

@@ -34,7 +34,7 @@ export function epiRange(from: string | number, to: string | number): string {

// find the current epiweek and date
const date = new Date();
const epidate = new EpiDate(date.getFullYear() + 1900, date.getMonth() + 1, date.getDate());
const epidate = new EpiDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that has been a curious artifact. I'm not sure how it slipped through QA, but it has no real ill effect, and it let us track epivis-based requests to the API servers. It looks like it came from an older piece of javascript where it presumably did the right thing (¯\_(ツ)_/¯). I am leaning towards leaving it as-is until #38 is done (especially so we can see the effect in our logs of more eyes on epivis with the signal discovery app's release). Do you have strong feelings either way?

@@ -150,13 +150,17 @@ export function loadDataSet(
});
}

export function fetchCOVIDcastMeta(): Promise<{ geo_type: string; signal: string; data_source: string }[]> {
export function fetchCOVIDcastMeta(): Promise<
{ geo_type: string; signal: string; data_source: string; time_type?: string }[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this filled in by your IDE because you use the .time_type member accessed in COVIDcast.svelte?

Why is the time_type marked "optional" with the question mark modifier? Is that just inherited from the importCOVIDcast() call signature definition? Or is it because the argument has a default value for time_type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was this filled in by your IDE because you use the .time_type member accessed in COVIDcast.svelte?

yes!

Was this filled in by your IDE because you use the .time_type member accessed in COVIDcast.svelte? Why is the time_type marked "optional" with the question mark modifier? Is that just inherited from the importCOVIDcast() call signature definition? Or is it because the argument has a default value for time_type?

Just inherited from that call.

src/api/EpiData.ts Outdated Show resolved Hide resolved
src/api/EpiData.ts Outdated Show resolved Hide resolved
src/api/EpiData.ts Outdated Show resolved Hide resolved
src/components/dialogs/dataSources/COVIDcast.svelte Outdated Show resolved Hide resolved
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
d.title = `${d.params._endpoint} | ${d.params.regions} | ${d.title}`;
d.title = `${Object.values(d.params).join(' > ')} > ${d.title}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a definite improvement and works well for now, but i wouldnt call this a full solution for #42 ... It lacks clarity and doesnt reproduce the normal/typical LeftMenu for a COVIDcast-type signal.

instead of:
covidcast > doctor-visits > smoothed_cli > day > state > ar > value,
it would be preferable to have something more like:
covidcast > doctor-visits:smoothed_cli > state:ar
for brevity and expressiveness

(lets leave it the way it is for now in this PR and return to it later when other higher-priority PRs are out of the way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented this now, as it's fairly straightforward to modify the template. lmk what you think!

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great for now. We should keep #42 open to later support reproducing the full form dropdown with value/stderr/sample_size.

@rzats rzats requested a review from melange396 August 8, 2024 12:58
@melange396 melange396 changed the title Improve handling for URL-based signals Improve handling for URL-based signals & support COVIDcast EpiWeeks Aug 9, 2024
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.

A couple little things, and then this'll be ready to go!

src/deriveLinkDefaults.ts Show resolved Hide resolved
@@ -34,7 +34,7 @@ export function epiRange(from: string | number, to: string | number): string {

// find the current epiweek and date
const date = new Date();
const epidate = new EpiDate(date.getFullYear() + 1900, date.getMonth() + 1, date.getDate());
const epidate = new EpiDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
Copy link
Contributor

Choose a reason for hiding this comment

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

That server logging would do it if, as cmu-delphi/delphi-epidata#1386 (comment) mentions and #38 references, we update the Referrer-Policy for epivis. Im not suggesting that adding 1900y is "clean", but can we leave it there for now and note that it should come out with #38?

// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
d.title = `${d.params._endpoint} | ${d.params.regions} | ${d.title}`;
d.title = `${Object.values(d.params).join(' > ')} > ${d.title}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great for now. We should keep #42 open to later support reproducing the full form dropdown with value/stderr/sample_size.

@rzats rzats requested a review from melange396 August 12, 2024 21:16
@rzats
Copy link
Contributor Author

rzats commented Aug 12, 2024

@melange396 updated this!

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.

nice work!

@melange396 melange396 merged commit 8baf276 into dev Aug 14, 2024
6 checks passed
@melange396 melange396 deleted the rzatserkovnyi/url-signals branch August 14, 2024 14:11
@melange396 melange396 mentioned this pull request Aug 22, 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.

Support EpiWeek-based "COVIDcast" signals
2 participants