def newcomer_issue_check(user, iss): """ True if: Issue is not labeled `difficulty/newcomer` and user is not a newcomer. False if: A `difficulty/newcomer` issue is already assigned to the user. """ if (self.is_newcomer_issue(iss) and self.is_team_member(user, 'newcomers')): search_query = 'user:coala assignee:{} ' \ 'label:difficulty/newcomer'.format(user) result = GitHub.raw_search( GitHubToken(self.config['GH_TOKEN']), search_query) return not (sum(1 for _ in result) >= 1) else: return True
def newcomer_issue_check(user, iss): """ True if: Issue is not labeled `difficulty/newcomer` and user is not a newcomer. False if: A `difficulty/newcomer` issue is already assigned to the user. """ if (self.is_newcomer_issue(iss) and self.TEAMS[self.GH_ORG_NAME + ' newcomers'].is_member(user)): search_query = 'user:coala assignee:{} ' \ 'label:difficulty/newcomer'.format(user) result = GitHub.raw_search( GitHubToken(os.environ.get('GH_TOKEN')), search_query) return not (sum(1 for _ in result) >= 1) else: return True
def _search_in_range( self, issue_type, created_after: Optional[datetime]=None, created_before: Optional[datetime]=None, updated_after: Optional[datetime]=None, updated_before: Optional[datetime]=None, state: Union[MergeRequestStates, IssueStates, None]=None ): """ Search for issue based on type 'issue' or 'pr' and return a list of issues. """ from IGitt.GitHub.GitHub import GitHub if state is None: query = ' type:' + issue_type + ' repo:' + self.full_name else: query = (' type:' + issue_type + ' is:' + state.value + ' repo:' + self.full_name) if ((created_after and created_before) or (updated_after and updated_before)): raise RuntimeError(('Cannot process before ' 'and after date simultaneously')) if created_after: query += (' created:>=' + str(created_after.strftime('%Y-%m-%dT%H:%M:%SZ'))) elif created_before: query += (' created:<' + str(created_before.strftime('%Y-%m-%dT%H:%M:%SZ'))) if updated_after: query += (' updated:>=' + str(updated_after.strftime('%Y-%m-%dT%H:%M:%SZ'))) elif updated_before: query += (' updated:<' + str(updated_before.strftime('%Y-%m-%dT%H:%M:%SZ'))) return list(GitHub.raw_search(self._token, query))