This commit is contained in:
2025-07-01 20:08:56 +09:00
parent e57ba6b2f0
commit 74971c923c
2 changed files with 15 additions and 1 deletions
+9 -1
View File
@@ -5,7 +5,15 @@ require 'nokogiri'
class PostsController < ApplicationController
# GET /posts
def index
posts = filtered_posts
latest_id = params[:latest].to_i
offset = params[:offset].to_i
posts = filtered_posts.order(created_at: :desc)
posts = if posts.first&.id == latest_id
posts.limit(20).offset(offset)
else
posts.limit(offset + 20)
end
render json: posts.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } })
end