Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

feat(clubhouse): Add global search #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 13 additions & 3 deletions src/sentry_plugins/clubhouse/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def get_configure_plugin_fields(self, request, project, **kwargs):
'type': 'text',
'placeholder': 'e.g. 639281',
'help': 'Enter your project\'s numerical ID.'
},
{
'name': 'global_search',
'label': 'Global Search',
'type': 'bool',
'required': False,
'help': 'When linking Sentry issues, search across all Clubhouse projects.'
}
]

Expand Down Expand Up @@ -128,16 +135,19 @@ def view_autocomplete(self, request, group, **kwargs):
if field != 'issue_id' or not query:
return Response({'issue_id': []})

search_globally = self.get_option('global_search', group.project)
project = self.get_option('project', group.project)

client = self.get_client(group.project)

# TODO: Something about the search API won't allow an explicit number search.
# Should it switch the search mechanism from search_stories(text) to get_story(id)?
try:
response = client.search_stories(
query=(u'project:%s %s' % (project, query)).encode('utf-8'),
)
if not search_globally:
# Modify the query string to include the project scope
query = u'project:%s %s' % (project, query)

response = client.search_stories(query=query.encode('utf-8'))
except Exception as e:
return self.handle_api_error(e)

Expand Down