       order_by: [desc: p.pr_xref]
   end
 
+  @spec all_for_project(Project.id, :open | :awaiting_review) :: Ecto.Queryable.t
   def all_for_project(project_id, :open) do
     from p in Patch,
       where: p.open,

    timestamps()
  end

  @doc """
  Builds a changeset based on the `struct` and `params`.
  """

      order_by: [desc: p.pr_xref]
  end

  @spec all_links_not_err() :: Ecto.Queryable.t
  defp all_links_not_err do
    from l in LinkPatchBatch,
      join: b in Batch,
      on: l.batch_id == b.id and b.state != ^:error and b.state != ^:canceled
  end

  @spec all(:awaiting_review) :: Ecto.Queryable.t
  def all(:awaiting_review) do
    all = all_links_not_err()
    from p in Patch,
