This commit is contained in:
2025-07-11 02:05:16 +09:00
parent b83fc6369a
commit 3c89d14636
9 changed files with 191 additions and 66 deletions
@@ -0,0 +1,24 @@
class NicoTagsController < ApplicationController
def index
limit = (params[:limit] || 20).to_i
cursor = params[:cursor].presence
q = Tag.nico_tags.includes(:linked_tags)
q = q.where('tags.updated_at < ?', Time.iso8601(cursor)) if cursor
tags = q.limit(limit + 1)
next_cursor = nil
if tags.size > limit
next_cursor = tags.last.updated_at.iso8601(6)
tags = tags.first(limit)
end
render json: { tags: tags.map { |tag|
tag.as_json(include: :linked_tags)
}, next_cursor: }
end
def upload
end
end
+2 -6
View File
@@ -6,14 +6,10 @@ class PostsController < ApplicationController
# GET /posts
def index
limit = (params[:limit] || 20).to_i
cursor = params[:cursor]
cursor = params[:cursor].presence
q = filtered_posts.order(created_at: :desc)
next_cursor = nil
if cursor.present?
q = q.where('posts.created_at < ?', Time.iso8601(cursor))
end
q = q.where('posts.created_at < ?', Time.iso8601(cursor)) if cursor
posts = q.limit(limit + 1)