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 @@ def fetch_paginated(query, params, :offset, table_binding) do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec paginate(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()]
|
@spec paginate_list(list(), keyword()) :: list()
|
||||||
def paginate(query, options, method \\ :keyset, table_binding \\ nil)
|
def paginate_list(list, options) do
|
||||||
|
|
||||||
def paginate(list, options, _method, _table_binding) when is_list(list) do
|
|
||||||
offset = options[:offset] || 0
|
offset = options[:offset] || 0
|
||||||
limit = options[:limit] || 0
|
limit = options[:limit] || 0
|
||||||
Enum.slice(list, offset, limit)
|
Enum.slice(list, offset, limit)
|
||||||
end
|
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
|
def paginate(query, options, :keyset, table_binding) do
|
||||||
query
|
query
|
||||||
|> restrict(:min_id, options, table_binding)
|
|> restrict(:min_id, options, table_binding)
|
||||||
|
|
|
@ -156,7 +156,7 @@ defp prepare_tags(query, options) do
|
||||||
tags
|
tags
|
||||||
end
|
end
|
||||||
|
|
||||||
Pleroma.Pagination.paginate(tags, options)
|
Pleroma.Pagination.paginate_list(tags, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_joined_tag(tags) do
|
defp add_joined_tag(tags) do
|
||||||
|
|
Loading…
Reference in New Issue