def _get_build_data(build):
    """
    Returns the given build model
    as formatted dict.

    Args:
        build (molior.model.build.Build): The build model.

    Returns:
        dict: The data dict.
    """
    maintainer = "-"
    if build.maintainer:
        maintainer = "{} {}".format(
            build.maintainer.firstname, build.maintainer.surname
        )

    data = {
        "id": build.id,
        "startstamp": str(build.startstamp),
        "endstamp": str(build.endstamp),
        "buildstate": build.buildstate,
        "buildtype": build.buildtype,
        "branch": build.ci_branch,
        "git_ref": build.git_ref,
        "sourcename": build.sourcename,
        "version": build.version,
        "maintainer": maintainer,
    }
    if build.sourcerepository:
        data.update(
            {
                "sourcerepository": {
                    "id": build.sourcerepository.id,
                    "url": build.sourcerepository.url,
                    "name": build.sourcerepository.name,
                }
            }
        )
    if build.buildconfiguration:
        data.update(
            {
                "buildvariant": {
                    "architecture": {
                        "id": build.buildconfiguration.buildvariant.architecture.id,
                        "name": build.buildconfiguration.buildvariant.architecture.name,
                    },
                    "basemirror": {
                        "id": build.buildconfiguration.buildvariant.base_mirror.id,
                        "version": build.buildconfiguration.buildvariant.base_mirror.name,
                        "name": build.buildconfiguration.buildvariant.base_mirror.project.name,
                    },
                    "name": build.buildconfiguration.buildvariant.name,
                },
                "projectversion_id": build.buildconfiguration.projectversions[0].id,
            }
        )
    return data