From 6d7ba2c5b15c0a12727ca444d1636517d68cd33a Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Fri, 17 May 2024 23:45:17 +0300 Subject: [PATCH 1/8] Update COVIDcast export integration --- src/modes/exportdata/ExportData.svelte | 5 ++-- src/modes/indicator/Indicator.svelte | 2 +- src/modes/indicator/IndicatorAbout.svelte | 31 +++++++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/modes/exportdata/ExportData.svelte b/src/modes/exportdata/ExportData.svelte index bde068c3..9d7d2181 100644 --- a/src/modes/exportdata/ExportData.svelte +++ b/src/modes/exportdata/ExportData.svelte @@ -55,7 +55,8 @@ startDate = urlParams.has('start_day') ? new Date(urlParams.get('start_day')) : param.sparkLineTimeFrame.min; endDate = urlParams.has('end_day') ? new Date(urlParams.get('end_day')) : param.sparkLineTimeFrame.max; - // Also normalize the dates to the current timezone + // Normalize the datest to the current timezone by *subtracting* the timezone + // offset (to account for negative timezones), multiplied by 60000 (minutes -> ms) startDate = new Date(startDate.getTime() - startDate.getTimezoneOffset() * -60000); endDate = new Date(endDate.getTime() - endDate.getTimezoneOffset() * -60000); } @@ -88,7 +89,7 @@ // Populate region based on URL params... but let the user override this later if (urlParams.has('geo_value') && !geoURLSet) { - let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_value')); + let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_value').toUpperCase()); addRegion(infos[0]); geoURLSet = true; } diff --git a/src/modes/indicator/Indicator.svelte b/src/modes/indicator/Indicator.svelte index 6e6e2987..e07186dd 100644 --- a/src/modes/indicator/Indicator.svelte +++ b/src/modes/indicator/Indicator.svelte @@ -96,7 +96,7 @@ - +

diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index e5ef07d8..5cd9f61f 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -1,10 +1,19 @@ {#if sensor.value.description} @@ -33,7 +60,7 @@ {/each}
  • - Export Data
  • From 8771297f50f9630737fa74da95fe0b92e4868695 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Fri, 17 May 2024 23:48:30 +0300 Subject: [PATCH 2/8] Only filter states --- src/modes/exportdata/ExportData.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modes/exportdata/ExportData.svelte b/src/modes/exportdata/ExportData.svelte index 9d7d2181..cbad4545 100644 --- a/src/modes/exportdata/ExportData.svelte +++ b/src/modes/exportdata/ExportData.svelte @@ -89,7 +89,12 @@ // Populate region based on URL params... but let the user override this later if (urlParams.has('geo_value') && !geoURLSet) { - let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_value').toUpperCase()); + let geo_value = urlParams.get('geo_value'); + // Allow for lowercase state names e.g. 'ca' -> 'CA' + if (geoType == 'state') { + geo_value = geo_value.toUpperCase(); + } + let infos = infosByLevel[geoType].filter((d) => d.propertyId == geo_value); addRegion(infos[0]); geoURLSet = true; } From 7dbe224853b9bd64f39ec25750a8f568cf1729eb Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Sat, 18 May 2024 00:32:04 +0300 Subject: [PATCH 3/8] Consider null sensor --- src/modes/indicator/IndicatorAbout.svelte | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index 5cd9f61f..3c2f1368 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -17,15 +17,14 @@ */ export let sensor; - function exportData() { - sensor.set(sensor.value); + function setExportMode() { // switch to export mode currentMode.set(modeByID.export); } function buildExportURL() { let exportURL = ''; - if (sensor.key.split('-').length >= 2) { + if (sensor && sensor.key.split('-').length >= 2) { // account for dashes in the sensor let [first, ...rest] = sensor.key.split('-'); rest = rest.join('-'); @@ -35,7 +34,6 @@ exportURL += `&geo_type=${region.level}&geo_value=${region.propertyId}`; } if (date) { - console.log(date); exportURL += `&start_day=${formatDateISO(date.value)}&end_day=${formatDateISO(date.value)}`; } return exportURL; @@ -60,9 +58,7 @@ {/each}
  • - Export Data + Export Data
  • {/if} From 4bfff8a555bccb2e7a7376fc7a9fcfd6f17ebe05 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Wed, 22 May 2024 16:56:43 +0300 Subject: [PATCH 4/8] dynamic updates --- src/modes/indicator/IndicatorAbout.svelte | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index 3c2f1368..f69ebba0 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -22,13 +22,14 @@ currentMode.set(modeByID.export); } - function buildExportURL() { - let exportURL = ''; + let exportURL = ''; + $: { + exportURL = ''; if (sensor && sensor.key.split('-').length >= 2) { // account for dashes in the sensor - let [first, ...rest] = sensor.key.split('-'); - rest = rest.join('-'); - exportURL += `data_source=${first}&signal=${rest}`; + let [last, ...rest] = sensor.key.split('-').reverse(); + rest = rest.reverse().join('-'); + exportURL += `data_source=${rest}&signal=${last}`; } if (region) { exportURL += `&geo_type=${region.level}&geo_value=${region.propertyId}`; @@ -36,7 +37,6 @@ if (date) { exportURL += `&start_day=${formatDateISO(date.value)}&end_day=${formatDateISO(date.value)}`; } - return exportURL; } @@ -58,7 +58,7 @@ {/each}
  • - Export Data + Export Data
  • {/if} From dc114422c7a80f48ea9300bf0f9c8aebe8ced8dd Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Wed, 22 May 2024 16:58:52 +0300 Subject: [PATCH 5/8] Also add comments --- src/modes/indicator/IndicatorAbout.svelte | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index f69ebba0..05edc0ae 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -26,16 +26,17 @@ $: { exportURL = ''; if (sensor && sensor.key.split('-').length >= 2) { - // account for dashes in the sensor + // Given a sensor key formatted "sensor-name-here-signal_name_here", split on the last dash let [last, ...rest] = sensor.key.split('-').reverse(); rest = rest.reverse().join('-'); exportURL += `data_source=${rest}&signal=${last}`; - } - if (region) { - exportURL += `&geo_type=${region.level}&geo_value=${region.propertyId}`; - } - if (date) { - exportURL += `&start_day=${formatDateISO(date.value)}&end_day=${formatDateISO(date.value)}`; + + if (region) { + exportURL += `&geo_type=${region.level}&geo_value=${region.propertyId}`; + } + if (date) { + exportURL += `&start_day=${formatDateISO(date.value)}&end_day=${formatDateISO(date.value)}`; + } } } From 8a887c92658616d39bd67f22a119a5e15f0387a5 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Sun, 23 Jun 2024 16:56:00 +0300 Subject: [PATCH 6/8] Fix type annotations --- src/modes/indicator/IndicatorAbout.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index 05edc0ae..6ad5e3c8 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -5,15 +5,15 @@ import AboutSection from '../../components/AboutSection.svelte'; /** - * @type {import("../stores/params").DateParam} + * @type {import("../../stores/params").DateParam} */ export let date; /** - * @type {import("../stores/params").RegionParam} + * @type {import("../../stores/params").RegionParam} */ export let region; /** - * @type {import("../stores/params").SensorParam} + * @type {import("../../stores/params").SensorParam} */ export let sensor; From af105daac37fc7635af6da82d640dc5d33fdda32 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Wed, 26 Jun 2024 01:52:21 +0300 Subject: [PATCH 7/8] Do not set state --- src/modes/indicator/IndicatorAbout.svelte | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index 6ad5e3c8..b1492437 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -1,7 +1,5 @@ @@ -140,7 +164,7 @@ {#if advanced}
  • - Advanced Data Export + Advanced Data Export
  • {/if} diff --git a/src/modes/indicator/GeoTable.svelte b/src/modes/indicator/GeoTable.svelte index 542022eb..c95afd6f 100644 --- a/src/modes/indicator/GeoTable.svelte +++ b/src/modes/indicator/GeoTable.svelte @@ -182,7 +182,7 @@
    {title.title} - row.dump} /> + row.dump} {date} {region} {sensor} />

    {@html mousePointerIcon} diff --git a/src/modes/indicator/IndicatorAbout.svelte b/src/modes/indicator/IndicatorAbout.svelte index b1492437..1fb5e27c 100644 --- a/src/modes/indicator/IndicatorAbout.svelte +++ b/src/modes/indicator/IndicatorAbout.svelte @@ -1,4 +1,6 @@