Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mhr-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mhr-api"
version = "2.1.7"
version = "2.1.8"
description = ""
authors = ["dlovett <doug@daxiom.com>"]
license = "BSD 3"
Expand Down
19 changes: 17 additions & 2 deletions mhr-api/src/mhr_api/models/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mhr-api/test_data/postgres_data_files/test0003.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
53 changes: 30 additions & 23 deletions mhr-api/tests/unit/models/test_search_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "6.0.4",
"version": "6.0.5",
"private": true,
"appName": "Assets UI",
"connectLayerName": "Core UI",
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/components/tables/mhr/SearchedResultsMhr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
>
<v-col cols="8">
<p class="no-results-title ma-0 pt-10">
<b>Nil Result</b>
<b>No Result</b>
</p>
<p class="ma-0 pt-2">
No registered homes can be found to match the
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/components/tables/ppr/SearchedResultsPpr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
>
<v-col>
<p class="no-results-title pt-10">
<b>Nil Result</b>
<b>No Result</b>
</p>
<p class="pt-2">
No registered liens or encumbrances have been found on file that match EXACTLY to the
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/tests/unit/SearchedResults.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
Loading