correct forum pagination

This commit is contained in:
byte[] 2019-10-08 19:37:14 -04:00
parent 94f521e99c
commit c28c3b914a

View file

@ -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)