def contributor(self, cid=None): if not cid: abort(404, detail="No contributor specified") c = Commits(index.Connector()) idents = Contributors() try: cid = utils.decrypt(xorkey, cid) except Exception: abort(404, detail="The cid is incorrectly formated") _, ident = idents.get_ident_by_id(cid) if not ident: # No ident has been declared for that contributor ident = list(idents.get_idents_by_emails(cid).values())[0] mails = ident['emails'] name = ident['name'] if not name: raw_names = c.get_commits_author_name_by_emails([cid]) if cid not in raw_names: # TODO: get_commits_author_name_by_emails must # support look by committer email too name = 'Unnamed' else: name = raw_names[cid] infos = {} infos['name'] = name infos['mails_amount'] = len(mails) infos['gravatar'] = hashlib.md5( ident['default-email'].encode(errors='ignore')).hexdigest() return infos
def contributor(self, cid=None): if not cid: abort(404, detail="No contributor specified") c = Commits(index.Connector()) idents = Contributors() try: cid = utils.decrypt(xorkey, cid) except Exception: abort(404, detail="The cid is incorrectly formated") _, ident = idents.get_ident_by_id(cid) if not ident: # No ident has been declared for that contributor ident = list(idents.get_idents_by_emails(cid).values())[0] mails = ident['emails'] name = ident['name'] if not name: raw_names = c.get_commits_author_name_by_emails([cid]) if cid not in raw_names: # TODO: get_commits_author_name_by_emails must # support look by committer email too name = 'Unnamed' else: name = raw_names[cid] infos = {} infos['name'] = name infos['mails_amount'] = len(mails) infos['gravatar'] = hashlib.md5( ident['default-email'].encode(errors='ignore')).hexdigest() return infos
def index(self, prefix=None, nameonly='false', withstats='false'): ci = Commits(index.Connector()) contributors_index = Contributors() groups = contributors_index.get_groups() if nameonly == 'true': ret = dict([(k, None) for k in groups.keys()]) if prefix: ret = dict([(k, None) for k in ret.keys() if k.lower().startswith(prefix)]) return ret ret_groups = {} for group, data in groups.items(): if prefix and not group.lower().startswith(prefix.lower()): continue rg = {'members': {}, 'description': data['description'], 'domains': data.get('domains', [])} emails = data['emails'].keys() members = contributors_index.get_idents_by_emails(emails) for id, member in members.items(): member['gravatar'] = hashlib.md5( member['default-email']).hexdigest() # TODO(fbo): bounces should be a list of bounce # Let's deactivate that for now # member['bounces'] = bounces del member['emails'] if not member['name']: # Try to find it among commits suggested = ci.get_commits_author_name_by_emails( [member['default-email']]) name = suggested.get(member['default-email'], 'Unknown name') member['name'] = name del member['default-email'] rg['members'][utils.encrypt(xorkey, id)] = member if withstats == 'true': # TODO(fbo): This endpoint needs to handle some filters like # dates bounces to return more accurate stats # Fetch the number of projects and repos contributed to p_filter = {} query_kwargs = { 'mails': data['emails'], 'merge_commit': False, 'repos': p_filter, } projects = Projects() tops_ctl = tops.TopProjectsController() top_projects = tops_ctl.gbycommits( ci, projects, query_kwargs, False) top_repos = tops_ctl.gbycommits( ci, projects, query_kwargs, True) rg['projects_amount'] = len(top_projects) rg['repos_amount'] = len(top_repos) ret_groups[group] = rg return ret_groups
def index(self, prefix=None, nameonly='false', withstats='false', pid=None, dfrom=None, dto=None, inc_merge_commit=None): ci = Commits(index.Connector()) contributors_index = Contributors() groups = contributors_index.get_groups() if withstats == 'true': projects_index = Projects() if nameonly == 'true': ret = dict([(k, None) for k in groups.keys()]) if prefix: ret = dict([(k, None) for k in ret.keys() if k.lower().startswith(prefix)]) return ret ret_groups = {} for group, data in groups.items(): if prefix and not group.lower().startswith(prefix.lower()): continue rg = {'members': {}, 'description': data.get('description', ''), 'domains': data.get('domains', [])} emails = list(data['emails'].keys()) members = contributors_index.get_idents_by_emails(emails) for id, member in members.items(): member['gravatar'] = hashlib.md5( member['default-email'].encode( errors='ignore')).hexdigest() # TODO(fbo): bounces should be a list of bounce # Let's deactivate that for now # member['bounces'] = bounces del member['emails'] if not member['name']: # Try to find it among commits suggested = ci.get_commits_author_name_by_emails( [member['default-email']]) name = suggested.get(member['default-email'], 'Unnamed') member['name'] = name del member['default-email'] rg['members'][utils.encrypt(xorkey, id)] = member if withstats == 'true': # Fetch the number of projects and repos contributed to query_kwargs = utils.resolv_filters( projects_index, contributors_index, pid, None, None, group, dfrom, dto, None, inc_merge_commit, None, None, None) repos = [r for r in ci.get_repos(**query_kwargs)[1] if not r.startswith('meta_ref: ')] projects = utils.get_projects_from_references( projects_index, repos) rg['repos_amount'] = len(repos) rg['projects_amount'] = len(projects) ret_groups[group] = rg return ret_groups
def contributor(self, cid=None): if not cid: abort(404, detail="No contributor specified") try: cid = utils.decrypt(xorkey, cid) except Exception: abort(404, detail="The cid is incorrectly formated") c = Commits(index.Connector()) idents = Contributors() projects = Projects() _, ident = idents.get_ident_by_id(cid) if not ident: # No ident has been declared for that contributor ident = idents.get_idents_by_emails(cid).values()[0] mails = ident['emails'] name = ident['name'] if not name: raw_names = c.get_commits_author_name_by_emails([cid]) if cid not in raw_names: # TODO: get_commits_author_name_by_emails must # support look by committer email too name = 'Unnamed' else: name = raw_names[cid] p_filter = {} query_kwargs = { 'mails': mails, 'merge_commit': False, 'repos': p_filter, } tops_ctl = tops.TopProjectsController() top_projects = tops_ctl.gbycommits(c, projects, query_kwargs, False) top_repos = tops_ctl.gbycommits(c, projects, query_kwargs, True) infos = {} infos['name'] = name infos['mails_amount'] = len(mails) infos['projects_amount'] = len(top_projects) infos['repos_amount'] = len(top_repos) infos['gravatar'] = hashlib.md5(ident['default-email']).hexdigest() return infos
def index(self, prefix=None, nameonly='false', withstats='false', pid=None, dfrom=None, dto=None, inc_merge_commit=None): ci = Commits(index.Connector()) contributors_index = Contributors() groups = contributors_index.get_groups() if withstats == 'true': projects_index = Projects() if nameonly == 'true': ret = dict([(k, None) for k in groups.keys()]) if prefix: ret = dict([(k, None) for k in ret.keys() if k.lower().startswith(prefix)]) return ret ret_groups = {} for group, data in groups.items(): if prefix and not group.lower().startswith(prefix.lower()): continue rg = { 'members': {}, 'description': data.get('description', ''), 'domains': data.get('domains', []) } emails = list(data['emails'].keys()) members = contributors_index.get_idents_by_emails(emails) for id, member in members.items(): member['gravatar'] = hashlib.md5( member['default-email'].encode( errors='ignore')).hexdigest() # TODO(fbo): bounces should be a list of bounce # Let's deactivate that for now # member['bounces'] = bounces del member['emails'] if not member['name']: # Try to find it among commits suggested = ci.get_commits_author_name_by_emails( [member['default-email']]) name = suggested.get(member['default-email'], 'Unnamed') member['name'] = name del member['default-email'] rg['members'][utils.encrypt(xorkey, id)] = member if withstats == 'true': # Fetch the number of projects and repos contributed to query_kwargs = utils.resolv_filters( projects_index, contributors_index, pid, None, None, group, dfrom, dto, None, inc_merge_commit, None, None, None) repos = [ r for r in ci.get_repos(**query_kwargs)[1] if not r.startswith('meta_ref: ') ] projects = utils.get_projects_from_references( projects_index, repos) rg['repos_amount'] = len(repos) rg['projects_amount'] = len(projects) ret_groups[group] = rg return ret_groups