def projects(self, pid=None): projects_index = Projects() if pid: project = projects_index.get(pid) if not project: abort(404, detail="Project ID has not been found") return {pid: projects_index.get(pid)} else: projects = projects_index.get_projects( source=['name', 'description', 'logo', 'refs']) _projects = OrderedDict( sorted(projects.items(), key=lambda t: t[0])) return {'projects': _projects, 'tags': projects_index.get_tags()}
def tags(self, pid=None, tid=None, dfrom=None, dto=None, inc_repos=None): t = Tags(index.Connector()) projects_index = Projects() idents = Contributors() query_kwargs = utils.resolv_filters(projects_index, idents, pid, tid, None, None, dfrom, dto, inc_repos, None, None, None, None) p_filter = [":".join(r.split(':')[:-1]) for r in query_kwargs['repos']] dfrom = query_kwargs['fromdate'] dto = query_kwargs['todate'] ret = [r['_source'] for r in t.get_tags(p_filter, dfrom, dto)] # TODO: if tid is given we can include user defined releases # for repo tagged with tid. if not pid: return ret # now append user defined releases ur = {} project = projects_index.get(pid, source=['refs', 'releases']) for release in project.get('releases', []): ur[release['name']] = release for ref in project['refs']: for release in ref.get('releases', []): ur[release['name']] = release for rel in ur.values(): ret.append(rel) return ret
def repos(self, pid=None, tid=None): projects_index = Projects() if not pid and not tid: abort(404, detail="A tag ID or project ID must be passed as parameter") if pid: project = projects_index.get(pid) else: if tid in projects_index.get_tags(): refs = projects_index.get_references_from_tags(tid) project = {'refs': refs} else: project = None if not project: abort(404, detail='Project ID or Tag ID has not been found') return project['refs']