diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/index.js b/assets/src/scripts/monitoring-location/components/hydrograph/index.js index f9a34453768d78f7549f4d6d7505fe399896c2d7..bf10a9464ff33af7f411cd5aaa32ad5e4209eb7e 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/index.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/index.js @@ -172,7 +172,7 @@ export const attachToNode = function(store, Promise.all(fetchDataPromises).then(() => { // selectedIVMethodID should be set regardless of whether we are showing only the graph but the preferred method ID // can not be determined until the data is fetched so that is done here. - const initialIVMethodID = timeSeriesId || getPreferredIVMethodID(store.getState()); + const initialIVMethodID = timeSeriesId || getPreferredIVMethodID('primary')(store.getState()); store.dispatch(setSelectedIVMethodID(initialIVMethodID)); showDataIndicators(false, store); diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.js index a44e8c7b087aade073d87090d89490276fb92180..1a92768c41eef787bbc6cff7a25f303bfbeafdc1 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.js @@ -183,8 +183,8 @@ export const getSortedIVMethods = dataKind => createSelector( * one method has the same point count, then the time series with the most recent point is chosen. * @returns {Function} which returns {String} the preferred method ID. */ -export const getPreferredIVMethodID = createSelector( - getSortedIVMethods('primary'), +export const getPreferredIVMethodID = dataKind => createSelector( + getSortedIVMethods(dataKind), (sortedMethods) => { return sortedMethods && sortedMethods.methods.length ? sortedMethods.methods[0].methodID : null; } diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js index dbc9e55de4ac16dd48520e54da3ace00cd25ec3f..6b6e85f488d5e0ce98de407a893afede71255e9b 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js @@ -457,7 +457,7 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m describe('getPreferredIVMethodID', () => { it('Return null if no hydrographData', () => { - expect(getPreferredIVMethodID({ + expect(getPreferredIVMethodID('primary')({ hydrographData: {}, groundwaterLevelData: { all: [] @@ -466,7 +466,7 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m }); it('Return null if no values for primary hydrograph data', () => { - expect(getPreferredIVMethodID({ + expect(getPreferredIVMethodID('primary')({ ...TEST_STATE, hydrographData: { primaryIVData: { @@ -483,11 +483,11 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m }); it('If all methods have no points return either methodID', () => { - expect(['69937', '252055'].includes(getPreferredIVMethodID(TEST_STATE))).toBe(true); + expect(['69937', '252055'].includes(getPreferredIVMethodID('primary')(TEST_STATE))).toBe(true); }); it('Return methodID for method that has points', () => { - expect(getPreferredIVMethodID({ + expect(getPreferredIVMethodID('primary')({ hydrographData: { ...TEST_STATE.hydrographData, primaryIVData: { @@ -511,7 +511,7 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m }); it('Return methodID for method with the most points', () => { - expect(getPreferredIVMethodID({ + expect(getPreferredIVMethodID('primary')({ hydrographData: { ...TEST_STATE.hydrographData, primaryIVData: { @@ -539,7 +539,7 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m }); it('If the methods have the same number of points return one with later dateTime', () => { - expect(getPreferredIVMethodID({ + expect(getPreferredIVMethodID('primary')({ hydrographData: { ...TEST_STATE.hydrographData, primaryIVData: {