예제 #1
0
    def index(self):
        documentation = "https://github.com/ceph/shaman#shaman"
        projects = Project.query.all()
        now = datetime.datetime.utcnow()
        # five days worth of data
        periods = [
            (now - datetime.timedelta(days=day-1), now - datetime.timedelta(days=day+1))
            for day in range(0, 10)
        ]
        area_data = []

        for upper_range, lower_range in periods:
            day = lower_range + datetime.timedelta(days=1)
            day_data = {'period': day.strftime("%Y-%m-%d")}
            for project in projects:
                repository_count = Repo.filter_by(
                    project=project).filter(Repo.status == "ready").filter(
                        and_(Repo.modified > lower_range),
                        and_(Repo.modified < upper_range)
                ).count()
                day_data[str(project.name)] = int(repository_count)
            area_data.append(day_data)

        latest_repos = Repo.query.filter_by(status="ready").order_by(desc(Repo.modified)).limit(10).all()
        latest_builds = Build.query.filter_by(status="completed").order_by(desc(Build.modified)).limit(10).all()

        return dict(
            description=description,
            documentation=documentation,
            area_data=str(area_data),
            projects=[str(p.name) for p in projects],
            latest_repos=latest_repos,
            latest_builds=latest_builds,
        )
예제 #2
0
    def index(self):
        repos = Repo.filter_by(project=self.project).order_by(desc(Repo.modified)).all()
        distinct = {
            "refs": list(set([b.ref for b in repos]))
        }

        return dict(
            project_name=self.project_name,
            distinct=distinct,
            builds=repos,
            section="Repos",
        )
예제 #3
0
    def index(self):
        repos = Repo.filter_by(
            project=self.project,
            ref=request.context['ref'],
            sha1=request.context['sha1'],
            flavor=self.flavor_name
        ).order_by(desc(Repo.modified)).all()

        return dict(
            project_name=self.project.name,
            builds=repos,
            breadcrumb="> {} > {} > {}".format(request.context['ref'], request.context['sha1'], self.flavor_name),
            section="Repos",
        )
예제 #4
0
    def index(self):
        repos = Repo.filter_by(
            project=self.project,
            ref=self.ref_name
        ).order_by(desc(Repo.modified)).all()

        distinct = {
            "sha1s": list(set([r.sha1 for r in repos]))
        }

        return dict(
            project_name=self.project.name,
            distinct=distinct,
            builds=repos,
            breadcrumb="> {}".format(self.ref_name),
            section="Repos",
        )
예제 #5
0
    def index(self):
        repos = Repo.filter_by(
            project=self.project,
            ref=request.context['ref'],
            sha1=self.sha1_name
        ).order_by(desc(Repo.modified)).all()

        distinct = {
            "flavors": list(set([r.flavor for r in repos]))
        }

        return dict(
            project_name=self.project.name,
            distinct=distinct,
            builds=repos,
            breadcrumb="> {} > {}".format(request.context['ref'], self.sha1_name),
            section="Repos",
        )
예제 #6
0
 def apply_filters(self, filters):
     # TODO: allow operators
     filters = deepcopy(filters)
     try:
         project = Project.filter_by(name=filters.pop('project')).first()
         query = Repo.filter_by(project=project)
     except KeyError:
         query = Repo.query
     if filters.get("distros", None):
         # TODO: we'll need some sort of schema validation here
         distro_list = util.parse_distro_query(filters.pop("distros"))
         distro_filter_list = []
         has_arch_filter = False
         for distro in distro_list:
             # for deb-based distros we store codename in the db as version,
             # so try first with the codename, but fallback to
             # distro_version otherwise
             version_filter = distro["distro_codename"] or distro['distro_version']
             if not version_filter:
                 abort(400, "Invalid version or codename for distro: %s" % distro["distro"])
             repo_filters = [Repo.distro == distro["distro"], Repo.distro_version == version_filter]
             if distro["arch"]:
                 repo_filters.append(Arch.name == distro["arch"])
                 has_arch_filter = True
             distro_filter_list.append(
                 and_(*repo_filters)
             )
         if has_arch_filter:
             query = query.join(Repo.archs).filter(or_(*distro_filter_list))
         else:
             query = query.filter(or_(*distro_filter_list))
     for k, v in filters.items():
         if k not in self.filters:
             # TODO: improve error reporting
             # 'invalid query params: %s' % k
             abort(400)
         if k in self.filters:
             query = self.filter_repo(k, v, query)
     return query
예제 #7
0
파일: root.py 프로젝트: yanghonggang/shaman
    def index(self):
        documentation = "https://github.com/ceph/shaman#shaman"
        projects = Project.query.all()
        now = datetime.datetime.utcnow()
        # five days worth of data
        periods = [(now - datetime.timedelta(days=day - 1),
                    now - datetime.timedelta(days=day + 1))
                   for day in range(0, 10)]
        area_data = []

        for upper_range, lower_range in periods:
            day = lower_range + datetime.timedelta(days=1)
            day_data = {'period': day.strftime("%Y-%m-%d")}
            for project in projects:
                repository_count = Repo.filter_by(project=project).filter(
                    Repo.status == "ready").filter(
                        and_(Repo.modified > lower_range),
                        and_(Repo.modified < upper_range)).count()
                # Do not add all the projects that haven't built anything for
                # the day
                if int(repository_count) == 0:
                    continue
                day_data[str(project.name)] = int(repository_count)
            area_data.append(day_data)

        latest_repos = Repo.query.filter_by(status="ready").order_by(
            desc(Repo.modified)).limit(10).all()
        latest_builds = Build.query.filter_by(status="completed").order_by(
            desc(Build.modified)).limit(10).all()

        return dict(
            description=description,
            documentation=documentation,
            area_data=str(area_data),
            projects=[str(p.name) for p in projects],
            latest_repos=latest_repos,
            latest_builds=latest_builds,
        )