[#1149] Merge remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job-queue

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Ivan Tashkinov 2019-09-03 17:12:15 +03:00
commit eb17cc17a1
3 changed files with 98 additions and 1 deletions

View file

@ -16,6 +16,15 @@ defmodule Pleroma.Pagination do
def fetch_paginated(query, params, type \\ :keyset)
def fetch_paginated(query, %{"total" => true} = params, :keyset) do
total = Repo.aggregate(query, :count, :id)
%{
total: total,
items: fetch_paginated(query, Map.drop(params, ["total"]), :keyset)
}
end
def fetch_paginated(query, params, :keyset) do
options = cast_params(params)
@ -25,6 +34,15 @@ defmodule Pleroma.Pagination do
|> enforce_order(options)
end
def fetch_paginated(query, %{"total" => true} = params, :offset) do
total = Repo.aggregate(query, :count, :id)
%{
total: total,
items: fetch_paginated(query, Map.drop(params, ["total"]), :offset)
}
end
def fetch_paginated(query, params, :offset) do
options = cast_params(params)