Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smartlink Error with Inline Case Search Fix #34834

Merged
merged 2 commits into from
Jun 28, 2024
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
16 changes: 10 additions & 6 deletions corehq/apps/case_search/tests/test_case_search_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def setUpClass(cls):
super().setUpClass()
cls.user = create_user("admin", "123")
CaseSearchConfig.objects.create(domain=cls.domain, enabled=True)
household_1 = str(uuid.uuid4())
cls.household_1 = str(uuid.uuid4())
case_blocks = [CaseBlock(
case_id=household_1,
case_id=cls.household_1,
case_type='household',
case_name="Villanueva",
create=True,
Expand All @@ -48,10 +48,10 @@ def setUpClass(cls):
update=properties,
index={'parent': IndexAttrs('household', household_id, 'child')} if household_id else None,
) for name, properties, household_id in [
("Jane", {"family": "Villanueva"}, household_1),
("Xiomara", {"family": "Villanueva"}, household_1),
("Alba", {"family": "Villanueva"}, household_1),
("Rogelio", {"family": "de la Vega"}, household_1),
("Jane", {"family": "Villanueva"}, cls.household_1),
("Xiomara", {"family": "Villanueva"}, cls.household_1),
("Alba", {"family": "Villanueva"}, cls.household_1),
("Rogelio", {"family": "de la Vega"}, cls.household_1),
("Jane", {"family": "Ramos"}, None),
]])
case_search_es_setup(cls.domain, case_blocks)
Expand All @@ -77,6 +77,10 @@ def test_basic(self):
case.name for case in res
])

def test_case_id_criteia(self):
res = get_case_search_results(self.domain, ['household'], [SearchCriteria('case_id', self.household_1)])
self.assertItemsEqual(["Villanueva"], [case.name for case in res])

def test_dynamic_property(self):
res = get_case_search_results(self.domain, ['person'], [SearchCriteria('family', 'Ramos')])
self.assertItemsEqual(["Jane"], [case.name for case in res])
Expand Down
3 changes: 3 additions & 0 deletions corehq/apps/case_search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from corehq import toggles
from corehq.apps.app_manager.dbaccessors import get_app_cached
from corehq.apps.app_manager.util import module_offers_search
from corehq.apps.es import cases as case_es
from corehq.apps.case_search.const import (
CASE_SEARCH_MAX_RESULTS,
COMMCARE_PROJECT,
Expand Down Expand Up @@ -269,6 +270,8 @@ def _apply_filter(self, search_es, criteria):
for xpath in xpaths:
search_es = search_es.filter(self._build_filter_from_xpath(xpath))
return search_es
elif criteria.key == 'case_id':
return search_es.filter(case_es.case_ids(criteria.value))
elif criteria.key == 'owner_id':
if not criteria.is_empty:
return search_es.filter(case_search.owner(criteria.value))
Expand Down
Loading