Skip to content

Commit

Permalink
Issue #479 - Add ability to pass existing params to get_search_results
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Taylor committed Dec 12, 2014
1 parent 9c77cfa commit 30743f3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions webcompat/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_issue_category(issue_category):
@api.route('/issues/search')
@limiter.limit('30/minute',
key_func=lambda: get_username())
def get_search_results(query_string=None):
def get_search_results(query_string=None, params=None):
'''XHR endpoint to get results from GitHub's Search API.
We're specifically searching "issues" here, which seems to make the most
Expand All @@ -156,13 +156,11 @@ def get_search_results(query_string=None):
Not cached.
'''
params = params or request.args.copy()
query_string = query_string or params.get('q')
search_uri = 'https://api.github.com/search/issues'
# TODO: handle sort and order parameters.
params = request.args.copy()

if query_string is None:
query_string = params.get('q')
# restrict results to our repo.
# restrict results to our repo.
query_string += " repo:{0}".format(REPO_PATH)
params['q'] = query_string

Expand All @@ -188,13 +186,14 @@ def get_category_from_search(issue_category):
issues from /issues/category/<issue_category>.
'''
category_list = ['contactready', 'needsdiagnosis', 'sitewait']
params = request.args.copy()

if issue_category in category_list:
query_string = 'label:{0}'.format(issue_category)
elif issue_category == 'untriaged':
query_string = ('state:open -label:contactready '
'-label:sitewait -label:needsdiagnosis')
return get_search_results(query_string)
return get_search_results(query_string, params)


@api.route('/issues/<int:number>/comments', methods=['GET', 'POST'])
Expand Down

0 comments on commit 30743f3

Please sign in to comment.