def get_latest_build(self, results, many, **kwargs):
     if results:
         with nplusone.ignore("eager_load"):
             builds = dict(fetch_builds_for_revisions(results))
         for item in results:
             item.latest_build = builds.get((item.repository_id, item.sha))
     return results
Example #2
0
    def get(self, repo: Repository):
        """
        Return a list of revisions for the given repository.
        """
        page = int(request.args.get("page", 1))
        if not (page > 0):
            page = 1

        parent = request.args.get("parent")

        revisions, has_more = self.fetch_revisions(repo, page, parent=parent)
        if revisions:
            builds = dict(fetch_builds_for_revisions(repo, revisions))
            for revision in revisions:
                revision.latest_build = builds.get(revision.sha)

        if not parent:
            base_url = self.build_base_url(without=["page", "parent"])
            if page == 1:
                base_url += "&parent={}".format(revisions[0].sha)
            else:
                base_url += "&parent=head"
        else:
            base_url = None

        response = self.respond_with_schema(revisions_schema, revisions)
        return self.build_paged_response(
            response,
            page + 1 if has_more else None,
            page - 1 if page > 1 else None,
            base_url=base_url,
        )
Example #3
0
 def get_latest_build(self, results, many):
     if results:
         builds = dict(
             fetch_builds_for_revisions(
                 [d.head_revision for d in results if d.head_revision]))
         for item in results:
             item.latest_build = builds.get(item.head_revision_sha)
     return results
Example #4
0
    def get(self, repo: Repository):
        """
        Return a list of revisions for the given repository.
        """
        revisions = self.fetch_revisions(repo)
        if revisions:
            builds = dict(fetch_builds_for_revisions(repo, revisions))
            for revision in revisions:
                revision.latest_build = builds.get(revision.sha)

        return self.respond_with_schema(revisions_schema, revisions)
Example #5
0
 def get_latest_build(self, results, many):
     if results:
         builds = dict(fetch_builds_for_revisions(results))
         for item in results:
             item.latest_build = builds.get((item.repository_id, item.sha))
     return results