def query_users(self, query, request): if not query: return try: bugzilla = Bugzilla(get_bugzilla_api_key(request.user)) except BugzillaError as e: raise UserQueryError('Bugzilla error: %s' % e.msg) try: # We don't want to auto populate just any user because Bugzilla has # over 300,000 users and most of them aren't relevant to MozReview. # # So, we only auto import users if they have IRC nick syntax or # if the search matches them exactly. def user_relevant(u): if BZ_IRCNICK_RE.search(u['real_name']): return True if u['email'] == query: return True # This might allow too many users through. Let's not get too # attached to this. if u['real_name'] == query: return True return False users = bugzilla.query_users(query) users['users'] = [u for u in users['users'] if user_relevant(u)] get_or_create_bugzilla_users(users) except BugzillaError as e: raise UserQueryError('Bugzilla error: %s' % e.msg)
def query_users(self, query, request): if not query: return try: bugzilla = Bugzilla(get_bugzilla_api_key(request.user)) except BugzillaError as e: raise UserQueryError('Bugzilla error: %s' % e.msg) try: # We don't want to auto populate just any user because Bugzilla has # over 300,000 users and most of them aren't relevant to MozReview. # # So, we only auto import users if they have IRC nick syntax or # if the search matches them exactly. def user_relevant(u): if BMO_IRC_NICK_RE.search(u['real_name']): return True if u['email'] == query: return True # This might allow too many users through. Let's not get too # attached to this. if u['real_name'] == query: return True return False users = bugzilla.query_users(query) users['users'] = [u for u in users['users'] if user_relevant(u)] logger.info( 'importing Bugzilla users from query "%s": %s' % (query, ', '.join(sorted(u['email'] for u in users['users'])))) get_or_create_bugzilla_users(users) except BugzillaError as e: raise UserQueryError('Bugzilla error: %s' % e.msg)