mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
correct forum pagination
This commit is contained in:
parent
94f521e99c
commit
c28c3b914a
1 changed files with 2 additions and 0 deletions
|
@ -16,10 +16,12 @@ defmodule PhilomenaWeb.TopicController do
|
||||||
|> Repo.one()
|
|> Repo.one()
|
||||||
|
|
||||||
conn = conn |> assign(:topic, topic)
|
conn = conn |> assign(:topic, topic)
|
||||||
|
%{page_number: page, page_size: page_size} = conn.assigns.pagination
|
||||||
|
|
||||||
posts =
|
posts =
|
||||||
Post
|
Post
|
||||||
|> where(topic_id: ^conn.assigns.topic.id)
|
|> where(topic_id: ^conn.assigns.topic.id)
|
||||||
|
|> where([p], p.topic_position >= ^(25 * (page - 1)) and p.topic_position < ^(25 * page))
|
||||||
|> order_by(asc: :created_at)
|
|> order_by(asc: :created_at)
|
||||||
|> preload([:user, topic: :forum])
|
|> preload([:user, topic: :forum])
|
||||||
|> Repo.paginate(conn.assigns.scrivener)
|
|> Repo.paginate(conn.assigns.scrivener)
|
||||||
|
|
Loading…
Reference in a new issue