Visitar URL original
first pass at search_issues · github3py/github3py@2699272 · GitHub
Skip to content

Commit 2699272

Browse files
esacteksabsigmavirus24
authored andcommitted
first pass at search_issues
Conflicts: github3/api.py github3/github.py tests/integration/test_github.py
1 parent b363299 commit 2699272

4 files changed

Lines changed: 131 additions & 1 deletion

File tree

‎github3/api.py‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,62 @@ def search_code(query, sort=None, order=None, per_page=None,
411411
etag)
412412

413413

414+
def search_issues(query, sort=None, order=None, per_page=None,
415+
text_match=False, number=-1, etag=None):
416+
"""Find issues by state and keyword
417+
418+
.. warning::
419+
420+
You will only be able to make 5 calls with this or other search
421+
functions. To raise the rate-limit on this set of endpoints, create an
422+
authenticated :class:`GitHub <github3.github.GitHub>` Session with
423+
``login``.
424+
425+
The query can contain any combination of the following supported
426+
qualifers:
427+
428+
- ``in`` Qualifies which fields are searched. With this qualifier you
429+
can restrict the search to just the repository name, description,
430+
readme, or any combination of these.
431+
- ``type`` With this qualifier you can restrict the search to issues or
432+
pull request only.
433+
- ``author`` Finds issues created by a certain user.
434+
- ``assignee`` Finds issues that are assigned to a certain user.
435+
- ``mentions`` Finds issues that mention a certain user.
436+
- ``commenter`` Finds issues that a certain user commented on.
437+
- ``involves`` Finds issues that were either created by a certain user,
438+
assigned to that user, mention that user, or were commented on by that
439+
user.
440+
- ``created`` or ``updated`` Filters issues based on times of
441+
creation, or when they were last updated. Format: ``YYYY-MM-DD``.
442+
Examples: ``created:<2011``, ``pushed:<2013-02``,
443+
``pushed:>=2013-03-06``
444+
- ``user`` or ``repo`` Limits searches to a specific user or repository.
445+
- ``language`` Searches for issues within repositories that match a
446+
certain language.
447+
- ``comments`` Filters issues based on the quantity of comments.
448+
- ``labels`` Filters issues based on their labels.
449+
450+
For more information about these qualifiers, see: http://git.io/d1oELA
451+
452+
:param str query: (required), a valid query as described above, e.g.,
453+
``windows label:bug``
454+
:param str sort: (optional), how the results should be sorted;
455+
options: ``created``, ``comments``, ``updated``; default: best match
456+
:param str order: (optional), the direction of the sorted results,
457+
options: ``asc``, ``desc``; default: ``desc``
458+
:param int per_page: (optional)
459+
:param bool text_match: (optional), if True, return matching search
460+
terms. See http://git.io/QLQuSQ for more information
461+
:param int number: (optional), number of issues to return.
462+
Default: -1, returns all available issues
463+
:param str etag: (optional), previous ETag header value
464+
:return: generator of :class:`Issue <github3.issues.Issue>`
465+
"""
466+
return gh.search_issues(query, sort, order, per_page, text_match,
467+
number, etag)
468+
469+
414470
def search_repositories(query, sort=None, order=None, per_page=None,
415471
text_match=False, number=-1, etag=None):
416472
"""Find repositories via various criteria.

‎github3/github.py‎

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ def search_code(self, query, sort=None, order=None, per_page=None,
10171017
options: ``asc``, ``desc``; default: ``desc``
10181018
:param int per_page: (optional)
10191019
:param bool text_match: (optional), if True, return matching search
1020-
terms. See http://git.io/4ct1eQ for more information
1020+
terms. See http://git.io/iRmJxg for more information
10211021
:param int number: (optional), number of repositories to return.
10221022
Default: -1, returns all available repositories
10231023
:param str etag: (optional), previous ETag header value
@@ -1042,6 +1042,70 @@ def search_code(self, query, sort=None, order=None, per_page=None,
10421042
return SearchIterator(number, url, CodeSearchResult, self, params,
10431043
etag, headers)
10441044

1045+
def search_issues(self, query, sort=None, order=None, per_page=None,
1046+
text_match=False, number=-1, etag=None):
1047+
"""Find issues by state and keyword
1048+
1049+
The query can contain any combination of the following supported
1050+
qualifers:
1051+
1052+
- ``in`` Qualifies which fields are searched. With this qualifier you
1053+
can restrict the search to just the repository name, description,
1054+
readme, or any combination of these.
1055+
- ``type`` With this qualifier you can restrict the search to issues or
1056+
pull request only.
1057+
- ``author`` Finds issues created by a certain user.
1058+
- ``assignee`` Finds issues that are assigned to a certain user.
1059+
- ``mentions`` Finds issues that mention a certain user.
1060+
- ``commenter`` Finds issues that a certain user commented on.
1061+
- ``involves`` Finds issues that were either created by a certain user,
1062+
assigned to that user, mention that user, or were commented on by
1063+
that user.
1064+
- ``created`` or ``updated`` Filters issues based on times of
1065+
creation, or when they were last updated. Format: ``YYYY-MM-DD``.
1066+
Examples: ``created:<2011``, ``pushed:<2013-02``,
1067+
``pushed:>=2013-03-06``
1068+
- ``user`` or ``repo`` Limits searches to a specific user or repository
1069+
- ``language`` Searches for issues within repositories that match a
1070+
certain language.
1071+
- ``comments`` Filters issues based on the quantity of comments.
1072+
- ``labels`` Filters issues based on their labels.
1073+
1074+
For more information about these qualifiers, see: http://git.io/d1oELA
1075+
1076+
:param str query: (required), a valid query as described above, e.g.,
1077+
``windows label:bug``
1078+
:param str sort: (optional), how the results should be sorted;
1079+
options: ``created``, ``comments``, ``updated``;
1080+
default: best match
1081+
:param str order: (optional), the direction of the sorted results,
1082+
options: ``asc``, ``desc``; default: ``desc``
1083+
:param int per_page: (optional)
1084+
:param bool text_match: (optional), if True, return matching search
1085+
terms. See http://git.io/QLQuSQ for more information
1086+
:param int number: (optional), number of issues to return.
1087+
Default: -1, returns all available issues
1088+
:param str etag: (optional), previous ETag header value
1089+
:return: generator of :class:`Issue <github3.issues.Issue>`
1090+
"""
1091+
params = {'q': query}
1092+
headers = {}
1093+
1094+
if sort in ('comments', 'created', 'updated'):
1095+
params['sort'] = sort
1096+
1097+
if order in ('asc', 'desc'):
1098+
params['order'] = order
1099+
1100+
if text_match:
1101+
headers = {
1102+
'Accept': 'application/vnd.github.v3.full.text-match+json'
1103+
}
1104+
1105+
url = self._build_url('search', 'issues')
1106+
return SearchIterator(number, url, Issue, self, params, etag,
1107+
headers)
1108+
10451109
def search_repositories(self, query, sort=None, order=None,
10461110
per_page=None, text_match=False, number=-1,
10471111
etag=None):

0 commit comments

Comments
 (0)