Fakultas Ilmu Komputer UI

Commit 4540a0fb authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Create Controller for Post Pagination

parent 462ccd21
defmodule DiskuyWeb.PostPagesController do
use DiskuyWeb, :controller
alias Diskuy.ForumPostPage
alias Diskuy.Repo
# Pages Per threads
def pages_thread(conn, %{"thread_id" => thread_id, "page" => page_num}) do
page = ForumPostPage.page_per_thread(thread_id) |> Repo.paginate(page: page_num)
with %{entries: _entries} <- page do
render(conn, "pages.json", %{page: page})
end
end
def pages_thread(conn, %{"thread_id" => thread_id}) do
page = ForumPostPage.page_per_thread(thread_id) |> Repo.paginate()
with %{entries: _entries} <- page do
render(conn, "pages.json", %{page: page})
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment