end
end
- def collection(collection, iri, page, _total \\ nil) do
+ def collection(collection, iri, page, total \\ nil) do
offset = (page - 1) * 10
items = Enum.slice(collection, offset, 10)
items = Enum.map(items, fn user -> user.ap_id end)
- total = _total || length(collection)
+ total = total || length(collection)
map = %{
"id" => "#{iri}?page=#{page}",
"type" => "OrderedCollectionPage",
"partOf" => iri,
- "totalItems" => length(collection),
+ "totalItems" => total,
"orderedItems" => items
}
- if offset < length(collection) do
+ if offset < total do
Map.put(map, "next", "#{iri}?page=#{page + 1}")
end
end
field(:valid_until, :naive_datetime)
field(:used, :boolean, default: false)
belongs_to(:user, Pleroma.User)
- belongs_to(:app, Pleroma.App)
+ belongs_to(:app, App)
timestamps()
end
field(:refresh_token, :string)
field(:valid_until, :naive_datetime)
belongs_to(:user, Pleroma.User)
- belongs_to(:app, Pleroma.App)
+ belongs_to(:app, App)
timestamps()
end