       nil -> %WB{project_id: project.id, number: build_counter, id: nil}
       build -> build
     end
-  end
-
-
-  # more or less copied from https://github.com/elixir-ecto/ecto/pull/1951/files/86c01b5fb524cae3871e8f62e67ab83da0923406
-  # it should arrive in Ecto > 2.1.4
-  defp multi_insert_or_update(multi, name,
-      %Changeset{data: %{__meta__: %{state: :loaded}}} = changeset) do
-    Multi.insert(multi, name, changeset)
-  end
-  defp multi_insert_or_update(multi, name, %Changeset{} = changeset) do
-    Multi.update(multi, name, changeset)
   end
 
   @doc """

    build_changeset = project
    |> create_build(counter)
    |> WB.changeset(summerize_build_event(ev))
    Logger.error("build changeset: #{inspect build_changeset}")
    project_changeset = WP.changeset(project, %{last_build_id: counter})
    # db_action = Multi.new
    # |> multi_insert_or_update(:build, build_changeset)
    # |> Multi.update(:project, project_changeset)
    # Repo.transaction(db_action)
    {:ok, b} = Repo.insert_or_update(build_changeset)
    {:ok, p} = Repo.update(project_changeset)
    {:ok, convert_up b}
  end


  """
  @spec list_projects() :: [Project.t]
  def list_projects() do
    Repo.all(WP) |> Enum.map &convert_up/1
  end

  @doc """
