def mark_build_archived(build_uuid): """ Mark a build as archived, and return True if we were the ones who actually updated the row. """ return (RepositoryBuild.update(logs_archived=True).where( RepositoryBuild.uuid == build_uuid, RepositoryBuild.logs_archived == False).execute()) > 0
def update_phase_then_close(build_uuid, phase): """ A function to change the phase of a build """ with UseThenDisconnect(config.app_config): try: build = _get_build_row(build_uuid) except RepositoryBuild.DoesNotExist: return False # Can't update a cancelled build if build.phase == BUILD_PHASE.CANCELLED: return False updated = (RepositoryBuild.update(phase=phase).where( RepositoryBuild.id == build.id, RepositoryBuild.phase == build.phase).execute()) return updated > 0