From 4dc37d7d3291c6bb2035bb45266ff57757969086 Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Fri, 5 Jul 2024 12:04:49 -0400 Subject: [PATCH 1/5] elevation is "numeric", not "number", logging for dev --- src/components/App.tsx | 1 + src/constants.ts | 2 +- src/utils/codapHelpers.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index d2b55b3..2703ac3 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -40,6 +40,7 @@ export const App = () => { const weatherStations = getWeatherStations(); useEffect(() => { + console.log("| 0 | App []"); const init = async () => { const newState = await initializePlugin({pluginName: kPluginName, version: kVersion, dimensions: kInitialDimensions}); const isMapOpen = await hasMap(); diff --git a/src/constants.ts b/src/constants.ts index 55e8a9a..0cde804 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -122,7 +122,7 @@ export const kWeatherStationCollectionAttrs = [ name: "elevation", unit: "ft", precision: "0", - type: "number" + type: "numeric", }, { name: "isdID"}, { diff --git a/src/utils/codapHelpers.ts b/src/utils/codapHelpers.ts index 316077b..309609b 100644 --- a/src/utils/codapHelpers.ts +++ b/src/utils/codapHelpers.ts @@ -92,7 +92,9 @@ const hasMap = async () => { }; const createStationsDataset = async (stations: IWeatherStation[]) => { + console.log("| 1 | createStationDataset..."); let result = await createDataContext(kStationsDatasetName); + console.log("| 2 | ...result: ", result); if (!result.success) { console.warn(`Dataset, "${kStationsDatasetName}", creation failed`); return; From f781505f964a9a84c52a491527028f4b5b83809c Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Sat, 6 Jul 2024 16:20:45 -0400 Subject: [PATCH 2/5] tracing data (logging) --- src/components/App.tsx | 8 +++++++- src/hooks/use-codap-api.tsx | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 2703ac3..7e5db75 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -197,7 +197,7 @@ export const App = () => { const allDefined = (startDate && endDate && units && selectedFrequency && weatherStation && timezone); - if (data && allDefined) { + if (data.length && allDefined) { const formatDataProps = { data, timezone, @@ -207,7 +207,10 @@ export const App = () => { endDate, units }; + // so far traced up to here - no data when nothing + console.log("| formatDataProps.data: ", formatDataProps.data); const dataRecords = formatData(formatDataProps); + //console.log(" | dataRecords? ", dataRecords); const items = Array.isArray(dataRecords) ? dataRecords : [dataRecords]; const filteredItems = filterItems(items); setStatus({ @@ -289,7 +292,10 @@ export const App = () => { const tResult = await fetch(tRequest, {mode: "cors"}); setIsFetching(true); if (tResult.ok) { + console.log("| tResult: ", tResult); const theJSON = await tResult.json(); + // it was empty...so keep going up + //console.log("| theJSON (if this empty then gotta dig more): ", theJSON); await fetchSuccessHandler(theJSON); } else { let result = await tResult.text(); diff --git a/src/hooks/use-codap-api.tsx b/src/hooks/use-codap-api.tsx index 2466f2b..31ccb39 100644 --- a/src/hooks/use-codap-api.tsx +++ b/src/hooks/use-codap-api.tsx @@ -29,6 +29,7 @@ export const useCODAPApi = () => { }, [selectedFrequency, frequencies, attrs]); const createNOAAItems = async (items: IItem[]) => { + console.log("| createNOAAItems from items: ", items); await updateWeatherDataset(selectedDataTypes); // eslint-disable-next-line no-console console.log("noaa-cdo ... createNOAAItems with " + items.length + " case(s)"); From e71efe84ffbe0ed38f3fd035b02a092e1895c528 Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Sat, 6 Jul 2024 16:37:09 -0400 Subject: [PATCH 3/5] cleanup, retain test for empty data array --- src/components/App.tsx | 7 ------- src/hooks/use-codap-api.tsx | 1 - src/utils/codapHelpers.ts | 2 -- 3 files changed, 10 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 7e5db75..70e02cd 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -40,7 +40,6 @@ export const App = () => { const weatherStations = getWeatherStations(); useEffect(() => { - console.log("| 0 | App []"); const init = async () => { const newState = await initializePlugin({pluginName: kPluginName, version: kVersion, dimensions: kInitialDimensions}); const isMapOpen = await hasMap(); @@ -207,10 +206,7 @@ export const App = () => { endDate, units }; - // so far traced up to here - no data when nothing - console.log("| formatDataProps.data: ", formatDataProps.data); const dataRecords = formatData(formatDataProps); - //console.log(" | dataRecords? ", dataRecords); const items = Array.isArray(dataRecords) ? dataRecords : [dataRecords]; const filteredItems = filterItems(items); setStatus({ @@ -292,10 +288,7 @@ export const App = () => { const tResult = await fetch(tRequest, {mode: "cors"}); setIsFetching(true); if (tResult.ok) { - console.log("| tResult: ", tResult); const theJSON = await tResult.json(); - // it was empty...so keep going up - //console.log("| theJSON (if this empty then gotta dig more): ", theJSON); await fetchSuccessHandler(theJSON); } else { let result = await tResult.text(); diff --git a/src/hooks/use-codap-api.tsx b/src/hooks/use-codap-api.tsx index 31ccb39..2466f2b 100644 --- a/src/hooks/use-codap-api.tsx +++ b/src/hooks/use-codap-api.tsx @@ -29,7 +29,6 @@ export const useCODAPApi = () => { }, [selectedFrequency, frequencies, attrs]); const createNOAAItems = async (items: IItem[]) => { - console.log("| createNOAAItems from items: ", items); await updateWeatherDataset(selectedDataTypes); // eslint-disable-next-line no-console console.log("noaa-cdo ... createNOAAItems with " + items.length + " case(s)"); diff --git a/src/utils/codapHelpers.ts b/src/utils/codapHelpers.ts index 309609b..316077b 100644 --- a/src/utils/codapHelpers.ts +++ b/src/utils/codapHelpers.ts @@ -92,9 +92,7 @@ const hasMap = async () => { }; const createStationsDataset = async (stations: IWeatherStation[]) => { - console.log("| 1 | createStationDataset..."); let result = await createDataContext(kStationsDatasetName); - console.log("| 2 | ...result: ", result); if (!result.success) { console.warn(`Dataset, "${kStationsDatasetName}", creation failed`); return; From 9e0112beb31014a7a5d65c1b09f66ea60fb79040 Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Sun, 7 Jul 2024 09:52:41 -0400 Subject: [PATCH 4/5] log converted data --- src/utils/noaaApiHelper.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/noaaApiHelper.ts b/src/utils/noaaApiHelper.ts index fca1263..10dd681 100644 --- a/src/utils/noaaApiHelper.ts +++ b/src/utils/noaaApiHelper.ts @@ -21,6 +21,7 @@ const convertUnits = (data: any[]) => { }); return item; }); + console.log("| returning some convertedData:", convertedData); return convertedData; }; From 0113ed776441142410a99cd7ac26187adc3030ca Mon Sep 17 00:00:00 2001 From: Joe Bacal Date: Sun, 7 Jul 2024 13:38:12 -0400 Subject: [PATCH 5/5] cleanup --- src/utils/noaaApiHelper.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/noaaApiHelper.ts b/src/utils/noaaApiHelper.ts index 10dd681..fca1263 100644 --- a/src/utils/noaaApiHelper.ts +++ b/src/utils/noaaApiHelper.ts @@ -21,7 +21,6 @@ const convertUnits = (data: any[]) => { }); return item; }); - console.log("| returning some convertedData:", convertedData); return convertedData; };