diff --git a/CHANGELOG.md b/CHANGELOG.md index e5fc7d34398dcb9a2918e897426711764cac0f97..7ff23bd291fc83a2b68d7a765a950ace53c3ce7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Parameter codes with multiple methods will now show statistical data for each method available. - The hydrograph legend and time span shortcuts will now correctly display for calculated temperature parameter codes. - The DV graph will now have an inverted y-axis for only certain parameter codes. +- If a prefered parameter code is not available, the first parameter code in the parameter selection list will now be selected. ## [1.2.0](https://github.com/usgs/waterdataui/compare/waterdataui-1.1.0...waterdataui-1.2.0) - 2022-06-10 ### Added diff --git a/wdfn-server/waterdata/location_utils.py b/wdfn-server/waterdata/location_utils.py index b58881a416cae78edb56305bf57a36d100331a51..421d97ccc47045181cd5a4f590e48ced193fe945 100644 --- a/wdfn-server/waterdata/location_utils.py +++ b/wdfn-server/waterdata/location_utils.py @@ -365,7 +365,7 @@ def get_default_parameter_code(iv_parameters, gw_parameters): return parameter_code if iv_parameters: - return list(iv_parameters)[0] + return list(iv_parameters)[-1] if gw_parameters: - return list(gw_parameters)[0] + return list(gw_parameters)[-1] return '' diff --git a/wdfn-server/waterdata/tests/test_location_utils.py b/wdfn-server/waterdata/tests/test_location_utils.py index 4309046cfa89694e94966af42b826eb3a8554395..9d325c7e7cc684b352f176212b620ebb948b2bae 100644 --- a/wdfn-server/waterdata/tests/test_location_utils.py +++ b/wdfn-server/waterdata/tests/test_location_utils.py @@ -674,7 +674,14 @@ class TestGetDefaultParameterCode(TestCase): }, { '65536': {} }), ['00010', '00011']) - + self.assertEqual(get_default_parameter_code({ + '00035': {}, + '00036': {}, + '62614': {} + }, { + '00035': {}, + '65536': {} + }), '62614') def test_iv_only(self): self.assertEqual(get_default_parameter_code({ '00060', @@ -687,3 +694,7 @@ class TestGetDefaultParameterCode(TestCase): '72019': {}, '65536': {} }), '72019') + self.assertEqual(get_default_parameter_code({}, { + '00010': {}, + '65536': {} + }), '65536')