Esempio n. 1
0
 def get(self, build: Build):
     """
     Return a build.
     """
     with nplusone.ignore("eager_load"):
         build.source = Source.query.options(joinedload("revision"),
                                             joinedload("patch")).get(
                                                 build.source_id)
     build.stats = list(ItemStat.query.filter(ItemStat.item_id == build.id))
     return self.respond_with_schema(build_schema, build)
Esempio n. 2
0
 def get(self, build: Build):
     """
     Return a build.
     """
     with nplusone.ignore("eager_load"):
         build.revision = Revision.query.filter(
             Revision.sha == build.revision_sha,
             Revision.repository_id == build.repository_id,
         ).first()
     build.stats = list(ItemStat.query.filter(ItemStat.item_id == build.id))
     return self.respond_with_schema(build_schema, build)
Esempio n. 3
0
def merge_builds(target: Build, build: Build) -> Build:
    # explicitly unset the default id as target should begin as an empty instance
    target.id = None

    # Store the original build so we can retrieve its ID or number later, or
    # show a list of all builds in the UI
    target.original.append(build)

    # These properties should theoretically always be the same within a build
    # group, so merging is not necessary.  We assign here so the initial build
    # gets populated.
    target.source = build.source
    target.label = build.source.revision.message

    # Merge properties, if they already exist.  In the first run, everything
    # will be empty, since every group is initialized with an empty build.
    # Afterwards, we always use the more extreme value (e.g. earlier start
    # date or worse result).
    target.stats = target.stats + build.stats if target.stats else build.stats
    target.status = (
        Status(max(target.status.value, build.status.value))
        if target.status
        else build.status
    )
    target.result = (
        Result(max(target.result.value, build.result.value))
        if target.result
        else build.result
    )
    target.date_started = (
        min(target.date_started, build.date_started)
        if target.date_started and build.date_started
        else target.date_started or build.date_started
    )
    target.date_finished = (
        max(target.date_finished, build.date_finished)
        if target.date_finished and build.date_finished
        else target.date_finished or build.date_finished
    )
    target.provider = (
        "%s, %s" % (target.provider, build.provider)
        if target.provider
        else build.provider
    )

    # NOTE: The build number is not merged, as it would not convey any meaning
    # in the context of a build group.  In that fashion, build numbers should
    # not be used in the UI, until we create a better interface.

    # NOTE: We do not merge data here, as it is not really used in the UI
    # If there is an actual use for data, then it should be merged or appended

    return target