fix offset calculation

This commit is contained in:
byte[] 2019-12-22 16:05:41 -05:00
parent 4bf223fe1a
commit 039db5a329

View file

@ -35,11 +35,10 @@ defmodule PhilomenaWeb.Image.NavigateController do
redirect(conn, to: Routes.image_path(conn, :index, page: page_num))
end
defp page_for_offset(_per_page, 0), do: 1
defp page_for_offset(per_page, offset) do
((offset + 1) / per_page)
|> Float.ceil()
|> trunc()
offset
|> div(per_page)
|> Kernel.+(1)
|> to_string()
end