From 59e18972d689cd054f31c7b90e927a6e1cbcf888 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 14 Mar 2024 17:07:45 -0400 Subject: [PATCH 1/4] Keep track of how much time the advanced weather view is open. --- src/SolarEclipse2024.vue | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/SolarEclipse2024.vue b/src/SolarEclipse2024.vue index ef6b68fe..68284b56 100644 --- a/src/SolarEclipse2024.vue +++ b/src/SolarEclipse2024.vue @@ -1708,8 +1708,10 @@ export default defineComponent({ uuid, infoTimeMs: 0, + weatherTimeMs: 0, appStartTimestamp: Date.now(), infoStartTimestamp: null as number | null, + weatherStartTimestamp: null as number | null, responseOptOut: responseOptOut as boolean | null, showSplashScreen: queryData.splash ?? true, @@ -2802,7 +2804,7 @@ export default defineComponent({ headers: { "Authorization": process.env.VUE_APP_CDS_API_KEY ?? "" } }); const content = await response.json(); - const exists = response.status === 200 && content.response.user_uuid != undefined; + const exists = response.status === 200 && content.response?.user_uuid != undefined; if (exists) { return; } @@ -2830,6 +2832,7 @@ export default defineComponent({ this.userSelectedLocations = []; this.cloudCoverSelectedLocations = []; this.infoTimeMs = 0; + this.weatherTimeMs = 0; this.appStartTimestamp = Date.now(); }, @@ -2850,7 +2853,10 @@ export default defineComponent({ // eslint-disable-next-line @typescript-eslint/naming-convention cloud_cover_selected_locations: toRaw(this.cloudCoverSelectedLocations), // eslint-disable-next-line @typescript-eslint/naming-convention - delta_info_time_ms: this.infoTimeMs, delta_app_time_ms: Date.now() - this.appStartTimestamp + delta_info_time_ms: this.infoTimeMs, delta_app_time_ms: Date.now() - this.appStartTimestamp, + // eslint-disable-next-line @typescript-eslint/naming-convention + delta_advanced_weather_time_ms: this.weatherTimeMs, + }), keepalive: true, }).then(() => { @@ -3570,11 +3576,19 @@ export default defineComponent({ if (show) { this.infoStartTimestamp = Date.now(); } else if (this.infoStartTimestamp !== null) { - const timestamp = Date.now(); - this.infoTimeMs += (timestamp - this.infoStartTimestamp); + this.infoTimeMs += (Date.now() - this.infoStartTimestamp); this.infoStartTimestamp = null; } }, + + showAdvancedWeather(show: boolean) { + if (show) { + this.weatherStartTimestamp = Date.now(); + } else if (this.weatherStartTimestamp !== null) { + this.weatherTimeMs += (Date.now() - this.weatherStartTimestamp); + this.weatherStartTimestamp = null; + } + }, introSlide(val: number) { this.inIntro = val < 4; From 1dd3f3c08776b3765afee37b8785ea589a55f8db Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 14 Mar 2024 19:08:26 -0400 Subject: [PATCH 2/4] Also account for case where one of the timed windows is open when the page is closed. --- src/SolarEclipse2024.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SolarEclipse2024.vue b/src/SolarEclipse2024.vue index 68284b56..ef58ad1d 100644 --- a/src/SolarEclipse2024.vue +++ b/src/SolarEclipse2024.vue @@ -1990,7 +1990,7 @@ export default defineComponent({ if (document.visibilityState === "hidden") { this.sendUpdateData(); } else { - this.clearData(); + this.resetData(); } }); @@ -2828,12 +2828,15 @@ export default defineComponent({ }); }, - clearData() { + resetData() { this.userSelectedLocations = []; this.cloudCoverSelectedLocations = []; this.infoTimeMs = 0; this.weatherTimeMs = 0; - this.appStartTimestamp = Date.now(); + const now = Date.now(); + this.appStartTimestamp = now; + this.infoStartTimestamp = this.showInfoSheet ? now : null; + this.weatherStartTimestamp = this.showAdvancedWeather ? now : null; }, sendUpdateData() { @@ -2860,7 +2863,7 @@ export default defineComponent({ }), keepalive: true, }).then(() => { - this.clearData(); + this.resetData(); }); }, From 2ba4214d9fe44401045b25ece0bcfcf4c2649a95 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 15 Mar 2024 08:49:51 -0400 Subject: [PATCH 3/4] Update what's sent in the update data. --- src/SolarEclipse2024.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SolarEclipse2024.vue b/src/SolarEclipse2024.vue index ef58ad1d..0d5bcca1 100644 --- a/src/SolarEclipse2024.vue +++ b/src/SolarEclipse2024.vue @@ -2843,6 +2843,9 @@ export default defineComponent({ if (this.responseOptOut) { return; } + const now = Date.now(); + const infoTime = (this.showInfoSheet && this.infoStartTimestamp !== null) ? now - this.infoStartTimestamp : this.infoTimeMs; + const weatherTime = (this.showAdvancedWeather && this.weatherStartTimestamp !== null) ? now - this.weatherStartTimestamp : this.weatherTimeMs; fetch(`${API_BASE_URL}/solar-eclipse-2024/data/${this.uuid}`, { method: "PATCH", headers: { @@ -2856,9 +2859,9 @@ export default defineComponent({ // eslint-disable-next-line @typescript-eslint/naming-convention cloud_cover_selected_locations: toRaw(this.cloudCoverSelectedLocations), // eslint-disable-next-line @typescript-eslint/naming-convention - delta_info_time_ms: this.infoTimeMs, delta_app_time_ms: Date.now() - this.appStartTimestamp, + delta_info_time_ms: infoTime, delta_app_time_ms: Date.now() - this.appStartTimestamp, // eslint-disable-next-line @typescript-eslint/naming-convention - delta_advanced_weather_time_ms: this.weatherTimeMs, + delta_advanced_weather_time_ms: weatherTime, }), keepalive: true, From c9dd2bc920760828fd3a718f327af48694ea328d Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 15 Mar 2024 12:25:07 -0400 Subject: [PATCH 4/4] Keep track of how long user has weather info open. --- src/AdvancedWeatherView.vue | 8 +++++--- src/SolarEclipse2024.vue | 21 ++++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/AdvancedWeatherView.vue b/src/AdvancedWeatherView.vue index a8abeeaf..ecd766e0 100644 --- a/src/AdvancedWeatherView.vue +++ b/src/AdvancedWeatherView.vue @@ -414,7 +414,7 @@ export default defineComponent({ 'define-term': DefineTerm, }, - emits: ['update:modelValue','close'], + emits: ['update:modelValue','close', 'explainer-open'], props: { modelValue: { @@ -1206,8 +1206,11 @@ export default defineComponent({ this.inBounds = inBounds; }); this.getLatLonIndex(value.latitudeDeg, value.longitudeDeg); - }, + + explainerOpen(open: boolean) { + this.$emit('explainer-open', open); + } }, @@ -1306,4 +1309,3 @@ export default defineComponent({ } -./utils \ No newline at end of file diff --git a/src/SolarEclipse2024.vue b/src/SolarEclipse2024.vue index 0d5bcca1..2675c09d 100644 --- a/src/SolarEclipse2024.vue +++ b/src/SolarEclipse2024.vue @@ -654,7 +654,8 @@ @close="() => { console.log('closing'); showAdvancedWeather = false; - }" + }" + @explainer-open="(open: boolean) => { weatherInfoOpen = open }" :default-location="locationDeg" />
{ @@ -3595,6 +3601,15 @@ export default defineComponent({ this.weatherStartTimestamp = null; } }, + + weatherInfoOpen(open: boolean) { + if (open) { + this.weatherInfoStartTimestamp = Date.now(); + } else if (this.weatherInfoStartTimestamp !== null) { + this.weatherInfoTimeMs += (Date.now() - this.weatherInfoStartTimestamp); + this.weatherInfoStartTimestamp = null; + } + }, introSlide(val: number) { this.inIntro = val < 4;