diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-03 10:08:07 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-03-03 10:08:07 +0300 |
commit | 509c81e4b10bd8ba6d3a93889cd6fbbbfbcbab21 (patch) | |
tree | 6939fe33f705c384bdf2bc05a348be02b64ec3fc /lib/pleroma/pagination.ex | |
parent | f987d83885eef7cd8d114feefe8870a8c5e841c6 (diff) | |
parent | 4c02e049358441529c54a72cd11f1c81ee897d49 (diff) | |
download | pleroma-509c81e4b10bd8ba6d3a93889cd6fbbbfbcbab21.tar.gz |
Merge branch 'develop' into gun
Diffstat (limited to 'lib/pleroma/pagination.ex')
-rw-r--r-- | lib/pleroma/pagination.ex | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pleroma/pagination.ex b/lib/pleroma/pagination.ex index 43fb7babf..d43a96cd2 100644 --- a/lib/pleroma/pagination.ex +++ b/lib/pleroma/pagination.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Pagination do @@ -12,12 +12,15 @@ defmodule Pleroma.Pagination do alias Pleroma.Repo + @type type :: :keyset | :offset + @default_limit 20 @max_limit 40 @page_keys ["max_id", "min_id", "limit", "since_id", "order"] def page_keys, do: @page_keys + @spec fetch_paginated(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()] def fetch_paginated(query, params, type \\ :keyset, table_binding \\ nil) def fetch_paginated(query, %{"total" => true} = params, :keyset, table_binding) do @@ -58,6 +61,7 @@ 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(query, options, :keyset, table_binding) do |