logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: ed2f8e45e9118177727b22f103f3c20476a891cf
parent c6f783c5519cc2cd519be4406366ecbad57a8c40
Author: Mark Felder <feld@feld.me>
Date:   Wed, 31 Jan 2024 11:12:41 -0500

Pleroma.Web.MastodonAPI.SearchController: fix dialyzer errors

Add a separate Pagination.paginate_list/2 function instead of overloading paginate/4 and complicating its matching and @spec

Diffstat:

Mlib/pleroma/pagination.ex9+++++----
Mlib/pleroma/web/mastodon_api/controllers/search_controller.ex2+-
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/pleroma/pagination.ex b/lib/pleroma/pagination.ex @@ -61,15 +61,16 @@ defmodule Pleroma.Pagination do |> Repo.all() end - @spec paginate(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()] - def paginate(query, options, method \\ :keyset, table_binding \\ nil) - - def paginate(list, options, _method, _table_binding) when is_list(list) do + @spec paginate_list(list(), keyword()) :: list() + def paginate_list(list, options) do offset = options[:offset] || 0 limit = options[:limit] || 0 Enum.slice(list, offset, limit) end + @spec paginate(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()] + def paginate(query, options, method \\ :keyset, table_binding \\ nil) + def paginate(query, options, :keyset, table_binding) do query |> restrict(:min_id, options, table_binding) diff --git a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex @@ -156,7 +156,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do tags end - Pleroma.Pagination.paginate(tags, options) + Pleroma.Pagination.paginate_list(tags, options) end defp add_joined_tag(tags) do