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
This commit is contained in:
Mark Felder 2024-01-31 11:12:41 -05:00
parent c6f783c551
commit ed2f8e45e9
2 changed files with 6 additions and 5 deletions

View File

@ -61,15 +61,16 @@ def fetch_paginated(query, params, :offset, table_binding) 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)

View File

@ -156,7 +156,7 @@ defp prepare_tags(query, options) do
tags
end
Pleroma.Pagination.paginate(tags, options)
Pleroma.Pagination.paginate_list(tags, options)
end
defp add_joined_tag(tags) do