Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Functional Programming
Diskuy-Backend
Commits
4540a0fb
Commit
4540a0fb
authored
Feb 08, 2021
by
Muhammad Rafif Elfazri
Browse files
Create Controller for Post Pagination
parent
462ccd21
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/diskuy_web/controllers/post_pages_controller.ex
0 → 100644
View file @
4540a0fb
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment