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

Allow interactions to be filtered by contact ID #5487

Merged
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
1 change: 1 addition & 0 deletions datahub/search/company/test/test_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def test_get_basic_search_query():
'company_number',
'contact.name',
'contact.name.trigram',
'contacts.id',
'contacts.name',
'contacts.name.trigram',
'country.trigram',
Expand Down
1 change: 1 addition & 0 deletions datahub/search/contact/test/test_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def test_get_basic_search_query():
'company_number',
'contact.name',
'contact.name.trigram',
'contacts.id',
'contacts.name',
'contacts.name.trigram',
'country.trigram',
Expand Down
3 changes: 2 additions & 1 deletion datahub/search/interaction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def _contact_field():
return Object(
properties={
'id': Keyword(index=False),
'id': Keyword(),
'first_name': Text(index=False),
'last_name': Text(index=False),
'name': Text(
Expand Down Expand Up @@ -139,6 +139,7 @@ class Interaction(BaseSearchModel):
'company.name.trigram',
'companies.name',
'companies.name.trigram',
'contacts.id',
'contacts.name', # to find 2-letter words
'contacts.name.trigram',
'event.name',
Expand Down
1 change: 1 addition & 0 deletions datahub/search/interaction/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SearchInteractionQuerySerializer(EntitySearchQuerySerializer):
service = SingleOrListField(child=StringUUIDField(), required=False)
sector_descends = SingleOrListField(child=StringUUIDField(), required=False)
was_policy_feedback_provided = serializers.BooleanField(required=False)
contacts = SingleOrListField(child=StringUUIDField(), required=False)

DEFAULT_ORDERING = SearchOrdering('date', SortDirection.desc)

Expand Down
2 changes: 2 additions & 0 deletions datahub/search/interaction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SearchInteractionAPIViewMixin:
'sector_descends',
'service',
'was_policy_feedback_provided',
'contacts',
)
REMAP_FIELDS = {
'company': 'company.id',
Expand All @@ -60,6 +61,7 @@ class SearchInteractionAPIViewMixin:
'policy_areas': 'policy_areas.id',
'policy_issue_types': 'policy_issue_types.id',
'service': 'service.id',
'contacts': 'contacts.id',
}

COMPOSITE_FILTERS = {
Expand Down
1 change: 1 addition & 0 deletions datahub/search/investment/test/test_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ def test_get_basic_search_query():
'company_number',
'contact.name',
'contact.name.trigram',
'contacts.id',
'contacts.name',
'contacts.name.trigram',
'country.trigram',
Expand Down
Loading