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:
parent
c6f783c551
commit
ed2f8e45e9
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user