This commit is contained in:
@@ -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
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user