diff --git a/mhr-api/pyproject.toml b/mhr-api/pyproject.toml index ca547d433..467b1ab8a 100644 --- a/mhr-api/pyproject.toml +++ b/mhr-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mhr-api" -version = "2.1.7" +version = "2.1.8" description = "" authors = ["dlovett "] license = "BSD 3" diff --git a/mhr-api/src/mhr_api/models/search_utils.py b/mhr-api/src/mhr_api/models/search_utils.py index ad8f43610..38c6d6bdf 100644 --- a/mhr-api/src/mhr_api/models/search_utils.py +++ b/mhr-api/src/mhr_api/models/search_utils.py @@ -143,10 +143,25 @@ WHERE compressed_key = mhr_serial_compressed_key(:query_value) """ SEARCH_SERIAL_WILD_QUERY_BASE = """ +WITH exact AS ( + SELECT mhr_number, status_type, registration_ts, city, serial_number, year_made, make, model, id, owner_info, + manufacturer_name, civic_address, section_id + FROM mhr_search_serial_vw + WHERE compressed_key = mhr_serial_compressed_key(:query_value) +), +combined AS ( + SELECT * + FROM exact +UNION ALL + SELECT mhr_number, status_type, registration_ts, city, serial_number, year_made, make, model, id, owner_info, + manufacturer_name, civic_address, section_id + FROM mhr_search_serial_vw + WHERE position(:query_value in serial_number) > 0 + AND NOT EXISTS (SELECT 1 FROM exact) +) SELECT mhr_number, status_type, registration_ts, city, serial_number, year_made, make, model, id, owner_info, manufacturer_name, civic_address - FROM mhr_search_serial_vw - WHERE position(:query_value in serial_number) > 0 +FROM combined """ SEARCH_SERIAL_DEAULT_ORDER = """ ORDER BY section_id diff --git a/mhr-api/test_data/postgres_data_files/test0003.sql b/mhr-api/test_data/postgres_data_files/test0003.sql index 38c1597eb..5cf88c85c 100644 --- a/mhr-api/test_data/postgres_data_files/test0003.sql +++ b/mhr-api/test_data/postgres_data_files/test0003.sql @@ -38,7 +38,7 @@ INSERT INTO mhr_descriptions(id, status_type, registration_id, csa_number, csa_s ; INSERT INTO mhr_sections(id, registration_id, status_type, compressed_key, serial_number, length_feet, length_inches, width_feet, width_inches, change_registration_id) - VALUES(200000015, 200000007, 'ACTIVE', mhr_serial_compressed_key('998765'), '998765', 60, 10, 14, 11, + VALUES(200000015, 200000007, 'ACTIVE', mhr_serial_compressed_key('M998765'), 'M998765', 60, 10, 14, 11, 200000007) ; INSERT INTO mhr_documents(id, document_type, registration_id, document_id, document_registration_number, attention_reference, @@ -109,7 +109,7 @@ INSERT INTO mhr_descriptions(id, status_type, registration_id, csa_number, csa_s ; INSERT INTO mhr_sections(id, registration_id, status_type, compressed_key, serial_number, length_feet, length_inches, width_feet, width_inches, change_registration_id) - VALUES(200000016, 200000008, 'ACTIVE', mhr_serial_compressed_key('9987'), '9987', 60, 10, 14, 11, + VALUES(200000016, 200000008, 'ACTIVE', mhr_serial_compressed_key('998765'), '998765', 60, 10, 14, 11, 200000008) ; INSERT INTO mhr_documents(id, document_type, registration_id, document_id, document_registration_number, attention_reference, diff --git a/mhr-api/tests/unit/models/test_search_request.py b/mhr-api/tests/unit/models/test_search_request.py index f77d23dee..71b174d1b 100755 --- a/mhr-api/tests/unit/models/test_search_request.py +++ b/mhr-api/tests/unit/models/test_search_request.py @@ -357,20 +357,23 @@ ('00900', '000900') ] # testdata pattern is -# ({search_value}, {count}, {mhr_num1}, {result_val1}, {mhr_num2}, {result_val2}, {wildcard}, {exact_match}) +# ({search_value}, {count}, {mhr_num1}, {result_val1}, {mhr_num2}, {result_val2}, {wildcard}, {prioritize}, {exact_match_found}) TEST_SERIAL_NUMBER_DATA = [ - ('999999', 0, None, None, None, None, False, False), - ('S60009493', 2, '000903', 'S60009493', '00904', '9493', False, False), - ('003000ZA002773B', 1, '000903', '003000ZA002773B', None, None, False, False), - ('PHH310OR1812828CRCM', 1, '000903', 'PHH310OR1812828CRCM', None, None, False, False), - ('0310282AB', 1, '000904', '0310282AB', None, None, False, False), - ('681323', 1, '000903', '681323', None, None, False, False), - ('681324', 1, '000905', '681324', None, None, False, False), - ('A4820717A', 1, '000904', 'A4820717A', '000905', 'A4820717B', False, False), - ('D1644', 2, '000901', 'D1644', '000902', '03A001644', False, False), - ('WIN24440204003A', 1, '000902', 'WIN24440204003A', '000902', 'WIN24440204003B', False, False), - ('9987', 2, '000907', '9987', '000906', '998765', True, False), - ('9987', 2, '000907', '9987', '000906', '998765', True, True) + ('999999', 0, None, None, None, None, False, False, False), + ('S60009493', 2, '000903', 'S60009493', '00904', '9493', False, False, False), + ('003000ZA002773B', 1, '000903', '003000ZA002773B', None, None, False, False, False), + ('PHH310OR1812828CRCM', 1, '000903', 'PHH310OR1812828CRCM', None, None, False, False, False), + ('0310282AB', 1, '000904', '0310282AB', None, None, False, False, False), + ('681323', 1, '000903', '681323', None, None, False, False, False), + ('681324', 1, '000905', '681324', None, None, False, False, False), + ('A4820717A', 1, '000904', 'A4820717A', '000905', 'A4820717B', False, False, False), + ('D1644', 2, '000901', 'D1644', '000902', '03A001644', False, False, False), + ('WIN24440204003A', 1, '000902', 'WIN24440204003A', '000902', 'WIN24440204003B', False, False, False), + ('998', 2, '000907', '998765', '000906', 'M998765', True, False, False), + ('998', 2, '000907', '998765', '000906', 'M998765', True, True, False), + ('998', 0, None, None, None, None, False, False, False), + ('998765', 2, '000907', '998765', '000906', 'M998765', True, False, True), + ('998765', 2, '000907', '998765', '000906', 'M998765', True, True, True), ] # testdata pattern is ({last_name}, {first_name}, count) @@ -557,14 +560,17 @@ def test_search_mhr_number(session, mhr_number, expected_number): assert result['results'][0]['mhrNumber'] == expected_number -@pytest.mark.parametrize('search_value,count,mhr1,result1,mhr2,result2,wildcard,exact_match', TEST_SERIAL_NUMBER_DATA) -def test_search_serial(session, search_value, count, mhr1, result1, mhr2, result2, wildcard, exact_match): +@pytest.mark.parametrize( + 'search_value,count,mhr1,result1,mhr2,result2,wildcard,prioritize,exact_match_found', TEST_SERIAL_NUMBER_DATA) +def test_search_serial( + session, search_value, count, mhr1, result1, mhr2, result2, wildcard, prioritize, exact_match_found +): """Assert that a valid search returns the expected serial number search result.""" test_data = copy.deepcopy(SERIAL_NUMBER_JSON) test_data['criteria']['value'] = search_value if wildcard: test_data['wildcardSearch'] = True - if exact_match: + if prioritize: test_data['prioritizeExactMatch'] = True query: SearchRequest = SearchRequest.create_from_json(test_data, 'PS12345', 'UNIT_TEST') @@ -593,13 +599,14 @@ def test_search_serial(session, search_value, count, mhr1, result1, mhr2, result assert match_count > 0 if wildcard: - assert len(result['results']) > 1 - if exact_match: - assert result['results'][0]['serialNumber'] == search_value - assert result['results'][-1]['serialNumber'] != search_value - elif exact_match: - assert len(result['results']) == 1 - assert result['results'][0]['serialNumber'] == search_value + assert len(result['results']) == count + if exact_match_found: + if prioritize: + assert result['results'][0]['serialNumber'] == search_value + assert result['results'][-1]['serialNumber'] != search_value + else: + assert result['results'][0]['serialNumber'] != search_value + assert result['results'][-1]['serialNumber'] == search_value @pytest.mark.parametrize('last_name,first_name,count', TEST_OWNER_IND_DATA) diff --git a/ppr-ui/package.json b/ppr-ui/package.json index 0a62f34eb..01a2ddd63 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "6.0.4", + "version": "6.0.5", "private": true, "appName": "Assets UI", "connectLayerName": "Core UI", diff --git a/ppr-ui/src/components/tables/mhr/SearchedResultsMhr.vue b/ppr-ui/src/components/tables/mhr/SearchedResultsMhr.vue index 836ec1fae..352ce5758 100644 --- a/ppr-ui/src/components/tables/mhr/SearchedResultsMhr.vue +++ b/ppr-ui/src/components/tables/mhr/SearchedResultsMhr.vue @@ -459,7 +459,7 @@ >

- Nil Result + No Result

No registered homes can be found to match the diff --git a/ppr-ui/src/components/tables/ppr/SearchedResultsPpr.vue b/ppr-ui/src/components/tables/ppr/SearchedResultsPpr.vue index 0f0da9aa8..9fb1bb7ef 100644 --- a/ppr-ui/src/components/tables/ppr/SearchedResultsPpr.vue +++ b/ppr-ui/src/components/tables/ppr/SearchedResultsPpr.vue @@ -294,7 +294,7 @@ >

- Nil Result + No Result

No registered liens or encumbrances have been found on file that match EXACTLY to the diff --git a/ppr-ui/tests/unit/SearchedResults.spec.ts b/ppr-ui/tests/unit/SearchedResults.spec.ts index 5d7b59c9b..2c27a7eb9 100644 --- a/ppr-ui/tests/unit/SearchedResults.spec.ts +++ b/ppr-ui/tests/unit/SearchedResults.spec.ts @@ -44,7 +44,7 @@ describe('Test result table with no results', () => { expect(datatable.length).toBe(0) const noResultsInfo = wrapper.findAll(noResultsDiv) expect(noResultsInfo.length).toBe(1) - expect(noResultsInfo.at(0).text()).toContain('Nil Result') + expect(noResultsInfo.at(0).text()).toContain('No Result') expect(noResultsInfo.at(0).text()).toContain('No registered liens or encumbrances') expect(wrapper.findAll(generateResult).length).toBe(1) })